Skip to content

avoid error when /compact response has no token_usage (#2417) - #2640

Merged
aibrahim-oai merged 3 commits into
openai:mainfrom
oyiakoumis:fix/compact-token-usage
Aug 25, 2025
Merged

aibrahim-oai merged 3 commits into
openai:mainfrom
oyiakoumis:fix/compact-token-usage

Conversation

@oyiakoumis

@oyiakoumis oyiakoumis commented Aug 24, 2025 •

Copy link
Copy Markdown
Contributor

Context
When running /compact, drain_to_completed would throw an error if token_usage was None in ResponseEvent::Completed. This made the command fail even though everything else had succeeded.

What changed

  • Instead of erroring, we now just check if let Some(token_usage) before sending the event.
  • If it’s missing, we skip it and move on.

Why
This makes AgentTask::compact() behave in the same way as AgentTask::spawn(), which also doesn’t error out when token_usage isn’t available. Keeps things consistent and avoids unnecessary failures.

Fixes
Closes #2417

@github-actions

github-actions Bot commented Aug 24, 2025 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@oyiakoumis

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@aibrahim-oai
aibrahim-oai enabled auto-merge (squash) August 25, 2025 17:14
@aibrahim-oai
aibrahim-oai merged commit a6c346b into openai:main Aug 25, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 25, 2025
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.

Bug Report: /compact Command Fails in Chat Completions API Mode

2 participants