Skip to content

fix(runtime): make turn acceptance retry-safe - #940

Closed
Neonforge98 wants to merge 1 commit into
developfrom
codex/durable-turn-receipts
Closed

fix(runtime): make turn acceptance retry-safe#940
Neonforge98 wants to merge 1 commit into
developfrom
codex/durable-turn-receipts

Conversation

@Neonforge98

Copy link
Copy Markdown
Collaborator

Problem

Exact response-loss retries were not accepted atomically across the native and external-CLI runtimes. Two native calls could both pass a read-before-upsert window, while a CLI retry could mutate model/account state or kill the live runner before discovering that the turn already existed. Project-mode submission also changed identity from the composer intent to a WorkItemRun without a durable X-to-Y receipt that callers could recover after losing the IPC response.

Solution

  • Claim ordinary native and CLI turn intents with an IMMEDIATE SQLite transaction before goal, runtime, transcript, config, process, steering, or scheduler side effects.
  • Return the original durable lifecycle for exact duplicates; distinguish the scheduler owner intent from a different intent that merely reuses the same client message id.
  • Keep Project mode single-owned by WorkItemRun, return an explicit duplicate receipt, store originTurnIntentId, and expose the effective WorkItemRun id.
  • Add agent_turn_intent_status so callers can recover status and effective identity after response loss.
  • Keep legacy WorkItemRun enqueue callers and native response consumers compatible; all response fields and commands are additive.

Potential risks

  • Project runs created before this change do not contain originTurnIntentId, so X-to-Y recovery applies to newly submitted turns only.
  • Status lookup checks the Project run store before falling back to the ordinary session intent store; malformed duplicate Project mappings fail closed instead of guessing.
  • A preparation failure closes a newly claimed intent as rejected; a deliberate retry after a returned error must use a new logical turn id.
  • This PR does not migrate frontend dispatch entry points, continuation storage, cloud plane formats, or UI. Those remain separate reviewable changes.

Verification

  • cargo test -p org2 exact_replay: 3 passed (initial, running, and completed retry paths)
  • session-persistence concurrent claim, agent-core receipt/scheduler, and project-management idempotency/status/recovery tests: passed
  • cargo check -p org2 -p agent_core -p session_persistence -p project_management --tests
  • cargo clippy -p org2 -p agent_core -p session_persistence -p project_management --tests -- -D warnings
  • pnpm typecheck
  • targeted CliRunReceipt Vitest: 2 passed
  • Pre-commit lint-staged, TypeScript, scoped clippy, and commit stats: passed

Architecture audit: no database schema migration, cloud API change, conversation-plane change, or new package-boundary dependency was introduced.

Atomically claim native and CLI turn intents before runtime, transcript, configuration, process, or scheduler side effects.

Return durable lifecycle receipts, preserve Project composer-to-WorkItemRun identity, and expose status recovery after IPC response loss.
@Harry19081 Harry19081 added bug Something isn't working agent Agent runtime, behavior, memory, providers, or orchestration project-management Projects, work items, routines, GitHub work, or team inbox labels Aug 25, 2026
@Neonforge98

Copy link
Copy Markdown
Collaborator Author

Superseded by the final two-PR design: #844 removes the Work Item-specific remote continuation bridge, and stacked #939 keeps the reusable audience routing plus sender-local provider-native continuation. This dispatcher/store/handoff stack is intentionally retired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Agent runtime, behavior, memory, providers, or orchestration bug Something isn't working project-management Projects, work items, routines, GitHub work, or team inbox

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants