fix(agent-core): harden goal-mode budget and outcome flow - #1456
Merged
Conversation
normalizeCompletionCriterion only trimmed whitespace, so the objective's 4000-character cap did not apply to completionCriterion. Since the criterion is repeated in every active/paused/blocked goal reminder, an unbounded one bloats state.json and every continuation prompt. Truncate it to the same limit (rather than rejecting, as it is a supplementary field).
…sted When the model records a user-stated budget the goal has already spent (e.g. 'one turn' after a turn was used), the tool persisted an over-budget goal but returned an ordinary result. Because the goal driver only enforces budgets at turn boundaries, the rest of the tool batch and the next model step ran past the ceiling. Predict the over-budget case to stop the batch (stopBatchAfterThis) and end the turn (stopTurn) so the driver blocks the goal at once.
…stion When an active goal reached its token budget, afterStep returned stopTurn, but shouldContinueAfterStop still flushed steer messages and ran the Stop hook, which could append a continuation and drive another model step past the hard ceiling. Guard the steer/Stop-hook continuations on stopForGoalBudget while the goal is still active, so a configured budget stays a deterministic stop and the driver blocks the goal at the boundary. A goal the model just marked terminal is no longer active, so its final outcome message still runs.
Selecting Auto/YOLO at the goal-start prompt switched the session permission before createGoal ran. If creation then failed (e.g. a goal already exists and replace was not given), the session was left in a more permissive mode with no goal started. Capture the previous mode and restore it when the goal does not start.
finalizeTurn shifts a queued user message out of queuedMessages and then
calls setAppState({ streamingPhase: 'idle' }), which synchronously retries
queued-goal promotion before the message's deferred send is scheduled. With
the queue momentarily empty and the phase idle, promotion could start a goal
ahead of the user's earlier queued message. Track a queuedMessageDispatchPending
flag across that window and require it to be clear before promoting.
The active-goal reminder formatted wall-clock values with a minutes-only formatter, so anything over an hour rendered as a large minute count (e.g. 120m00s) in the Progress and Budgets lines. Match the app's completion-card formatter so the same value renders consistently (2h00m).
🦋 Changeset detectedLatest commit: 6645fb2 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 |
chengluyu
marked this pull request as ready for review
July 7, 2026 04:45
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d359ae46f7
ℹ️ 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".
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UpdateGoalhandling so completion/blocker summary reminders are returned in the tool result.UpdateGoalso the model can write a concise user-facing summary.Related Issue
None
Problem
What changed
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.