DeepSeek-Reasonix icon indicating copy to clipboard operation
DeepSeek-Reasonix copied to clipboard

Make Goal completion fail closed / 让 Goal 完成判定安全停止

Open SivanCola opened this issue 4 months ago • 0 comments

Summary

  • Replace free-form Goal footer markers with a stable update_goal tool and epoch-scoped per-turn reports.
  • Make the Goal FSM the only continuation owner; Delivery now returns structured readiness without hidden retries.
  • Add a bounded independent evaluator, progress-aware turn/token budgets, usage attribution, pause/resume controls, and runtime status across CLI, Desktop, ACP, and Remote.

Problem

Goal mode previously interpreted a missing or malformed assistant footer as "not finished" and opened another turn. This made a complete first answer capable of continuing until the hard turn ceiling. Delivery readiness also maintained a separate hidden retry loop, so continuation ownership was split across two protocols.

Root cause

Completion state was encoded in free-form assistant text and failed open. The host had no single decision point combining explicit completion, delivery readiness, evaluator uncertainty, token/turn budgets, and progress detection.

What changed

  • Register update_goal with continue, complete, and blocked outcomes. Reports are idempotent within a turn, terminal conflicts and stale continuation epochs are rejected, and normal chats cannot mutate Goal state.
  • Centralize completion and continuation in advance(): explicit terminal state and readiness, blocked state, evaluator fail-closed behavior, budgets, no-progress checks, then continuation.
  • Run at most one isolated, bounded, tool-free evaluator when the model omits a Goal report. Timeout, invalid JSON, errors, and uncertain verdicts pause safely instead of continuing.
  • Reduce Delivery to a ReadinessResult service. Non-Goal Delivery stops after the first failed readiness check; Goal + Delivery feeds readiness into the Goal FSM.
  • Add simple/write/research budgets, four-turn no-progress protection, persisted runtime state, and compatible /goal status|pause|resume|clear plus Desktop/Remote/ACP controls.
  • Update the user and protocol documentation, tests, and changelog.

Compatibility and cache impact

  • Existing Goal sidecars derive compatible runtime defaults; paused Goals persist as blocked with a stop cause and can be resumed with an additional bounded allowance.
  • update_goal introduces one expected provider-visible tool-schema prefix change. Its registration, order, and serialization are stable, so toggling Goal does not create ongoing schema churn.
  • The provider-visible Delivery runtime marker remains byte-stable; the host state machine owns the responsibility split.

Verification

  • go test ./...
  • cd desktop && go test ./...
  • cd desktop/frontend && pnpm typecheck && pnpm test:all && pnpm build
  • go test -race ./internal/control ./internal/agent ./internal/recovery ./internal/goaleval ./internal/tool/... ./internal/evidence
  • ./scripts/cache-guard.sh
  • go run ./cmd/remote-protocol-gen -check -root .
  • git diff --check

Release note follow-up

The changelog and product documentation are updated here. release-notes/releases.json is a curated release-time index and should receive its entry during release preparation.

Cache-impact: high - update_goal intentionally adds one provider-visible tool schema; its registration, order, and serialization remain stable across turns. Cache-guard: ./scripts/cache-guard.sh passed with every guarded cache scenario at or above the 90% threshold. System-prompt-review: reviewed - Goal prompt changes use the stable update_goal contract and keep dynamic Goal state out of the provider-visible stable prefix. Documentation-impact: updated - Goal lifecycle, Delivery readiness, controls, protocol contracts, and user guidance are documented in both product docs and the changelog.

SivanCola avatar Aug 04 '26 18:08 SivanCola