Skip to content

fix(agent): persist Codex prompt token usage#3506

Merged
trunk-io[bot] merged 1 commit into
mainfrom
fix/codex-prompt-token-usage
Jul 16, 2026
Merged

fix(agent): persist Codex prompt token usage#3506
trunk-io[bot] merged 1 commit into
mainfrom
fix/codex-prompt-token-usage

Conversation

@tatoalo

@tatoalo tatoalo commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

Codex app-server sessions calculate per-turn token usage, but the adapter returned only the stop reason from prompt(). The agent server therefore had no usage data to persist on the task run, leaving Codex cloud-run token totals empty.

Changes

  • Return Codex token usage with the ACP prompt response
  • Preserve single ownership for steered prompts to avoid double-counting
  • Aggregate usage across plan handoff turns
  • Keep the existing PostHog usage notifications compatible
  • Extend the existing adapter tests for prompt, steering, plan handoff, and usage tracking

@trunk-io

trunk-io Bot commented Jul 16, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 45298c3.

@tatoalo tatoalo self-assigned this Jul 16, 2026
@tatoalo tatoalo added the Stamphog This will request an autostamp by stamphog on small changes label Jul 16, 2026
@tatoalo
tatoalo marked this pull request as ready for review July 16, 2026 12:23

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well-tested bug fix that properly threads token usage through the prompt response — no showstoppers, all callsites handle the updated undefined-return correctly, and the merging logic for multi-turn plan cycles is sound.

@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(agent): persist Codex prompt token u..." | Re-trigger Greptile

@tatoalo
tatoalo enabled auto-merge (squash) July 16, 2026 15:13
@trunk-io
trunk-io Bot merged commit 907250c into main Jul 16, 2026
39 checks passed
@trunk-io
trunk-io Bot deleted the fix/codex-prompt-token-usage branch July 16, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants