Skip to content

fix(coding-agent): cancel prompts before agent start - #143

Merged
Issacboy123 merged 5 commits into
fix/harden-subagent-message-guidancefrom
fix/cancel-prompts-before-start
Aug 29, 2026
Merged

Issacboy123 merged 5 commits into
fix/harden-subagent-message-guidancefrom
fix/cancel-prompts-before-start

Conversation

@Issacboy123

@Issacboy123 Issacboy123 commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

AgentSession.prompt() could not be cancelled reliably during asynchronous preflight, allowing overlapping work or a user/provider turn to begin after cancellation. This PR adds an optional prompt signal with synchronous lifecycle reservation, pre-start cancellation through authentication and compaction, and handoff to existing abort settlement after agent_start.

Reasoning

The prompt boundary is the narrowest place that owns admission, preflight, and active-run settlement. Reserving there closes overlap races without changing established queueing for unsignaled prompts. Pre-start cancellation preserves the caller's exact reason, while post-start cancellation reuses the session abort path so persistence and event semantics still have one terminal outcome. A rollback-capable compaction append is necessary because cancellation may arrive after persistence but before post-save extension notification completes.

Changes

  • Added PromptOptions.signal and synchronous reservations covering prompt preflight through settlement.
  • Rejected conflicting signaled prompts while preserving concurrent unsignaled preflight and existing active-run steering and follow-up behavior.
  • Propagated cancellation through authentication and pre-prompt compaction, with one prompt-owned abort listener removed on every terminal path.
  • Preserved exact pre-start abort reasons, pending next-turn messages, and the absence of user or provider turns after cancellation.
  • Added transactional compaction append and rollback support so cancelled preflight leaves no completed compaction entry, including while compaction hooks are pending.
  • Added focused prompt, callback-ordering, queueing, authentication, compaction, state-restoration, and listener-cleanup regressions.
  • Documented the prompt signal contract in the SDK guide and recorded the fix in the changelog.

Testing

  • node ../../node_modules/vitest/dist/cli.js --run test/suite/agent-session-prompt.test.ts test/session-manager/compaction-rollback.test.ts
  • node ../../node_modules/vitest/dist/cli.js --run test/suite/agent-session-prompt.test.ts test/suite/subagent-services.test.ts test/suite/subagent-registration.test.ts test/suite/subagent-coordination.test.ts test/suite/subagent-parent-messaging.test.ts test/subagent-controller.test.ts
  • npm run build
  • npm run check

@Issacboy123 Issacboy123 self-assigned this Aug 28, 2026
@Issacboy123 Issacboy123 added bug Something isn't working coding-agent labels Aug 28, 2026
@Pepps233
Pepps233 self-requested a review August 28, 2026 15:34
@Issacboy123
Issacboy123 merged commit 61f0fad into main Aug 29, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working coding-agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants