Repository navigation
goal: add timer-owned continuation handoff - #1
Conversation
|
Review request @jif-oai — could you review the Goal idle-lifecycle boundary, especially the @etraut-openai — could you review whether keeping the Goal @eternal-openai — could you review the automation ownership and dispatch contract against the Rust automation direction explored in openai#28609 through openai#28620? Reporter validation would also be very useful from @titanwings, @jerryfane, and @Countermarch. The intended acceptance behavior is:
The main design questions are:
The upstream repository currently rejects |
Desktop integration and protocol migrationThis PR intentionally stops at the Goal-side primitive. The shipped behavior changes only after Desktop wires its automation handler to the new continuation API. Required Desktop changesDo not replace the model-facing Only same-thread heartbeat/wakeup automations participate in the handoff. Detached cron automations that create a new thread remain unchanged. Desktop should persist the following binding metadata with a same-thread automation:
The binding metadata is host-owned and does not need to grant the model access to Goal APIs. Create and bindThe safest sequence is a two-phase automation mutation:
If step 4 fails, remove or disable the pending automation and return an Reschedule and recurring runs
One-shot delivery
If turn start fails or the target is busy, keep the timer binding and retry/defer. Clearing before the scheduled turn is accepted reopens the idle-loop race. Restoring Disable, delete, and target conversionUse the inverse two-phase order:
Do not use unconditional For deletion, keep a tombstone or non-dispatchable record until step 2 succeeds. This gives startup reconciliation enough information to retry cleanup after a crash. Model-facing automation protocolThe first Desktop release should extend the existing dynamic-tool schema additively:
This matches the App-server protocol migrationThe new methods are experimental. Desktop must:
Existing automation migrationExisting heartbeat automations have no Goal binding metadata. Migrate them lazily at startup or next update:
Startup reconciliation should also finish SQLite migration and rollbackThe Goal database migration is additive: it creates Older binaries can open a database with the newer applied migration because the runtime migrator ignores unknown newer versions. That is storage-compatible but not behavior-compatible: an older Goal runtime does not read the timer table and may resume idle continuation. Rollout order should therefore be:
Before downgrading to an app-server without this feature, disable new binding creation and clear existing timer bindings with the new binary. Do not rely on the older binary merely tolerating the table. Desktop acceptance matrix
|
5fa3e17 to
e17e0f2
Compare
Problem
An active Goal owns the thread-idle lifecycle. If the remaining work is deferred to a scheduled task, creating the schedule does not currently replace that idle continuation. The Goal can therefore start immediate synthetic turns while the scheduler is supposed to wait, as reported in openai#28923 and openai#28144.
Design
This change separates Goal state from the mechanism that starts its next turn:
The Goal remains active in both cases. Installing a timer trigger suppresses only automatic idle turns and idle accounting; it does not pause, complete, or grant the agent permission to mutate the Goal.
The handoff contract is:
thread/goal/continuation/getand retain its opaquegoalVersion.timerwithgoalVersion,automationId,generation, andnextRunAt.onIdleIfTimerwhile that turn is active.onIdleIfTimer.Concurrency and failure boundaries
goalVersionprevents an operation created for an old Goal from affecting a replacement Goal.automationIdgives one automation ownership of the continuation trigger.generationrejects stale schedule updates.What changed
thread/goal/continuation/getandthread/goal/continuation/setapp-server methods.Scope
This is the Goal-side handoff primitive. It does not modify the currently shipped Desktop
automation_updatehandler. That handler, or a future Rust automation extension such as the direction explored in openai#28609 through openai#28620, must call this API after a schedule mutation succeeds.The split is intentional: the agent keeps only
automation_updateauthority; the trusted host or automation service performs the internal Goal continuation handoff.Addresses openai#28923. Related: openai#28144, openai#35601, openai#29184, openai#32793.
Verification
just test -p codex-state: 184 passed.just test -p codex-goal-extension: 24 passed.just test -p codex-app-server-protocol: 294 passed, 1 skipped.just test -p codex-app-server timer_goal_continuation_suppresses_idle_until_restored: passed.codex-app-server: 1295/1300 passed; the five failures require unavailable local code-mode/executor fixtures and do not touch Goal paths. The new integration test passed in the full run.codex-state,codex-goal-extension,codex-app-server-protocol, andcodex-app-server.Workspace-wide Clippy was attempted but stopped in the unchanged code-mode-host dependency because the upstream
rusty_v8 v150.4.0macOS archive URL returned 404.