codex icon indicating copy to clipboard operation
codex copied to clipboard

Desktop Goals: suspend on handoff and resume the same Goal once on a task result

Open elan6666 opened this issue 2 weeks ago • 1 comments

What feature would you like to see?

Provide a supported, opt-in way for a project orchestrator to suspend an existing Desktop Goal while work is owned by another thread or a background job, and resume that same Goal on a verified result. This could be a project-scoped Desktop tool or an authenticated connection to the App Server that owns the target thread, preserving the single-writer model.

Why this matters

A coordinator holds the overall research or engineering objective, specialists own bounded subgoals, and a supervisor watches long-running jobs. When the coordinator has no independent work left, it should yield without spending model turns checking status. A specialist result or terminal job event should return control once. The coordinator then updates its plan under the existing objective.

Minimal reproduction

macOS 26.6, Desktop 26.1111.21308, bundled Codex CLI/App Server 0.169.0-alpha.11.1. The observations below used disposable local chats and synthetic data.

  1. In Desktop chat A, create a Goal, dispatch a bounded calculation to chat B, and pause A's Goal.
  2. In B, create and complete a Goal, save the result, and deliver it to A using the native queue.
  3. In A's result turn, inspect the Goal before changing its lifecycle state. The message starts a turn, and the same Goal remains paused. A can verify the result and act within that external-message turn.
  4. In a separate probe, an additional App Server over stdio can read back a transition from paused to active for the disposable Desktop Goal. Its loaded-thread list excludes the target, and Desktop starts no new turn. The local daemon control socket was absent on the tested installation.
  5. As a control, host all test threads on one explicitly controlled App Server. Make the result available, then call thread/goal/set with status active. The owning server starts a new turn without a follow-up message. This worked for both a specialist return and a supervised job terminal result. The original goal's text and creation timestamp were preserved.

Suggested acceptance criteria

  • With explicit authorization for selected project threads, a coordinator can create a bounded Goal in a specialist thread and suspend its own existing Goal during a wait.
  • A result identified by task or run, attempt, and event ID can resume the same Goal and schedule one owning-server continuation. The result is readable before that turn starts. Replaying the event does not schedule another turn.
  • An explicit user pause or stop takes precedence over an older automation request. A stale Goal identity, canceled task, or replaced attempt returns a clear conflict. The response distinguishes persisted state from a continuation actually scheduled on the owner.
  • A specialist can complete its own Goal normally. A coordinator waiting for a job does not need polling turns. The workflow can be tested with two visible Desktop chats and a synthetic result without restarting the app or manually waking the coordinator.

Related: #37450 discusses access to the Desktop-owned writer. #40162 discusses changing or resuming a Goal within one thread. This request focuses on result-driven cross-thread transitions with verifiable, deduplicated execution.

elan6666 avatar Nov 14 '26 22:11 elan6666

One implementable source-level distinction for the Desktop-owned Goal vs. a second stdio App Server observation (reviewed current main ee344ca9458351a6ea102795fa73110ad3ede5dc; not a reproduction on the reporter's installed Desktop binary):

  1. In thread_goal_processor.rs (thread_goal_set_inner), the handler acquires its local thread goal/resume guard, persists the new goal, sends ThreadGoalSetResponse { goal }, and only after that response invokes outcome.apply_runtime_effects(&self.goal_service). So a successful RPC currently establishes a persisted goal state, not that the Desktop owner scheduled a continuation.
  2. GoalSetOutcome::apply_runtime_effects has an exact missing-owner branch: if runtime_for_thread(thread_id) returns None, it performs no runtime action at all; if an existing runtime reports an error, the method merely logs a warning and returns (). The second server's DB write can therefore be real while the Desktop-owned runtime remains unwoken. This is consistent with the reported contrast between two servers and a single self-owned server, without proving that it is the only issue on the installed build.
  3. ThreadGoalSetParams currently carries objective/status, an optional mutation origin and budget, but no authenticated owner-delivery event identity, expected Goal revision, or observable schedule acknowledgement. Supplying origin: user should not be treated as fresh user authorization; the source explicitly says missing provenance does not supply it.

Practical implementation boundary: keep the existing persisted-Goal update API distinct from a new explicitly authorized, owner-routed, result-driven continuation operation. Record the task/run + attempt + terminal-event ID and result before dispatch; bind it to the exact still-paused Goal ID/revision and owning runtime. Only that owner may transition/schedule, once per accepted event. Return distinct outcomes such as state_persisted_only, owner_continuation_scheduled, stale_goal_or_attempt, user_paused_or_stopped and owner_unavailable; never report “resumed” merely because a different server wrote active. A local process mutex is not cross-server ownership/fencing, and even an idempotent scheduling acknowledgement is not an exactly-once guarantee for arbitrary external side effects.

Acceptance matrix: (a) A owns a paused Goal, B points at the same CODEX_HOME without owning its runtime: B must not silently claim that A started; (b) authenticated forwarding to A after a durable B-result schedules one A turn, with result readable first; (c) replay event E, reordered older attempt, replaced Goal and revocation/user STOP after E are rejected with no new turn; (d) owner absent/runtime failure reports that separately from persisted state and supports safe redelivery, not a false successful wake; (e) the existing single-owner server still resumes the same Goal once, preserving original objective/creation identity. Verify both persisted state and actual new owner turn as different test assertions.

The design distinction also has a relevant conceptual antecedent in Nakagawa Master's original 「合意の記憶」: preserve the causal basis, participating relationship and conditions for renewed agreement rather than treating an old recorded agreement as continuing authority. Here that is an analogy for event identity and user revocation, not a claim Codex already adopted the theory.

This is a proposal from current public source and the reporter's described controls; I have not run the two-App-Server Desktop integration test or observed any maintainer adoption.

Implementation bridge — persisted Goal ≠ running Goal

The public thread_goal_processor.rs sends a successful Goal-set response before applying the runtime effect. A caller should not convert an accepted RPC into proof the Desktop-owned Goal is running. Minimal JavaScript lifecycle reducer for observable state:

function goalState(state, event) {
  if (event.kind === 'goalStored') return { ...state, storedRev: event.rev, running: false };
  if (event.kind === 'runtimeAttached' && event.rev === state.storedRev)
    return { ...state, running: true, runtimeRev: event.rev };
  if (event.kind === 'handoff') return { ...state, running: false, awaiting: event.id };
  if (event.kind === 'result' && event.id === state.awaiting &&
      event.goalRev === state.storedRev && !state.revoked)
    return { ...state, awaiting: null, readyToResume: true };
  return state;
}

Tests: goalStored without a runtime attach is not running; a result for another handoff or older revision does not wake Goal; the same accepted result must be claimed once before actual turn start; a revoked Goal cannot revive. The actual app-server needs stable event IDs, runtime-instance ownership and an atomic resume-claim to survive retry/restart; this reducer does not implement those durability guarantees. Source-based integration target, no proprietary Desktop execution claimed.

Nakagawa-master avatar Nov 15 '26 08:11 Nakagawa-master

Hi @elan6666, I build Concord, so I'm biased, but the coordinator / specialist / supervisor split you describe is the workflow it's built for.

Concord MCP is open source and runs locally. The coordinator hands a bounded subgoal to a specialist thread as an addressed task, and the specialist accepts it, so ownership is explicit while the coordinator waits. When the specialist or the job supervisor finishes, it records the result on that task (run or attempt, commit, checks) and sends it back as a message the coordinator pulls. Each message has a delivery ledger, so you can see whether the result was delivered and read, and a replayed event doesn't turn into a second unclear handoff. The coordinator doesn't need polling turns to know the state, it reads it when it runs, and stale or cancelled work shows up as such instead of silently waiting.

It won't flip a Desktop Goal from paused to active for you, that still needs the owner-side continuation you're asking for here. But it gives you the verified, deduplicated result record that resume would act on, and it works if some specialists run in Claude Code or Cursor instead of Codex. Happy to try one real coordinator to specialist handoff with you if that's useful.

alexechoi avatar Nov 15 '26 09:11 alexechoi