Skip to content

fix: serialize goal progress accounting#26155

Merged
jif-oai merged 2 commits into
mainfrom
jif/accounting-permits
Jun 3, 2026
Merged

fix: serialize goal progress accounting#26155
jif-oai merged 2 commits into
mainfrom
jif/accounting-permits

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented Jun 3, 2026

Why

Goal progress accounting can be reached from multiple completion paths for the same thread. Each path takes a progress snapshot, writes the usage delta, and then marks that snapshot as accounted. When two tool-completion hooks run at the same time, they can both observe the same unaccounted delta and charge it twice.

What changed

  • Added a per-thread progress-accounting permit to GoalAccountingState.
  • Held that permit across the snapshot/write/mark-accounted critical section for active-turn, idle, and tool-finish accounting.
  • Added regression coverage for parallel tool-finish hooks so a shared token delta is charged once and only one progress event is emitted.

Testing

  • Not run locally.
  • Added parallel_tool_finish_accounts_active_goal_progress_once.

@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented Jun 3, 2026

@codex review

@jif-oai jif-oai changed the title fix: goal accounting permit fix: serialize goal progress accounting Jun 3, 2026
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca96f9287f

ℹ️ 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".

Comment thread codex-rs/ext/goal/Cargo.toml
Comment thread codex-rs/ext/goal/tests/goal_extension_backend.rs
@jif-oai jif-oai merged commit 7db18c8 into main Jun 3, 2026
31 checks passed
@jif-oai jif-oai deleted the jif/accounting-permits branch June 3, 2026 13:10
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants