feat: handle goal usage limits in goal extension#24628
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f16ba95d51
ℹ️ 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa7599ba36
ℹ️ 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".
Why
The extracted goal runtime needs a host-callable path for turns that stop because the workspace usage limit is reached. In that case, any in-turn goal progress should be accounted before the goal becomes terminal, and active goal accounting must be cleared so later tool-finish or turn-stop handling does not keep charging usage to a stopped goal.
What changed
GoalRuntimeHandle::usage_limit_active_goal_for_turn, which accounts current active-goal progress, marks the active or budget-limited thread goal asUsageLimited, records terminal metrics when the status changes, clears active goal accounting, and emits the updated goal event.ext/goal/tests/goal_extension_backend.rs, including the invariant that later token/tool events do not add usage after the goal has been usage-limited.Testing
usage_limit_active_goal_accounts_progress_and_clears_accounting.usage_limit_budget_limited_goal_accounts_remaining_progress.