fix(agent-core-v2): preserve goal continuations - #1696
Conversation
🦋 Changeset detectedLatest commit: e511716 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
When a live continuation is preserved here, pendingContinuation still holds the original MessageStepRequest receipt. After that first step completes and the budget/blocker path starts the tool-free final-status step, a later SDK/RPC pauseGoal, cancelGoal, or replacement still reaches cancelPendingContinuation(false) and only aborts that already-completed step receipt; the real loop does not cancel the active turn in that case, so the supposedly cancelled continuation can keep streaming to completion. Keep a handle to the assigned turn or call loop.cancel(turnId) when cancelling a live preserved continuation.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
8ed908a to
e511716
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Related Issue
No linked issue.
Problem
Automatic goal continuations keep their enqueue receipt until the assigned turn settles. When a continuation reached its token budget or the model called
UpdateGoal(blocked), the goal lifecycle transition treated that receipt as pending work and aborted the currently running continuation. The turn therefore stopped before it could produce the required tool-free final status or blocker explanation.User-initiated pause, cancel, and goal replacement must still cancel live goal work.
What changed
UpdateGoal(blocked)blocker explanations while retaining pause/cancel cancellation coverage.Validation:
pnpm --filter @moonshot-ai/agent-core-v2 exec vitest run test/agent/goal/goal.test.ts test/agent/goal/goalOps.test.ts test/agent/goal/tools/goal-tools.test.ts test/agent/goal/injection/goalInjection.test.ts(97 tests)pnpm --filter @moonshot-ai/agent-core-v2 test(3353 tests)pnpm --filter @moonshot-ai/agent-core-v2 typecheckpnpm --filter @moonshot-ai/agent-core-v2 lint:domainpnpm changeset statusgit diff --checkChecklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.