Skip to content

Act on reasoning-included per turn - #9402

Merged
aibrahim-oai merged 3 commits into
mainfrom
reasoning-included
Jan 19, 2026
Merged

aibrahim-oai merged 3 commits into
mainfrom
reasoning-included

Conversation

@aibrahim-oai

@aibrahim-oai aibrahim-oai commented Jan 17, 2026 •

Copy link
Copy Markdown
Contributor
  • Reset reasoning-included flag each turn and update compaction test

@aibrahim-oai

Copy link
Copy Markdown
Contributor Author

@codex review this

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

Copy link
Copy Markdown
Contributor

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: a44959ad27

ℹ️ 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 on lines +88 to +90
pub(crate) fn set_server_reasoning_included(&mut self, included: bool) {
self.server_reasoning_included |= included;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Avoid sticky reasoning-included flag across responses

The new set_server_reasoning_included uses |= so once any response sets the flag true it can never return to false. Because the header is only emitted when present, a later response that does not include X-Reasoning-Included (e.g., mixed backend versions during a rollout or different servers per SSE request) will still be treated as “included,” causing get_total_token_usage to skip estimating past reasoning tokens and undercount usage. That can suppress auto‑compaction decisions. Consider setting the flag to the current response’s value (not OR‑ing), or explicitly clearing it when the header is absent.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@codex fix this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

Testing

  • ✅ just fix -p codex-core
  • ❌ cargo test -p codex-core (failed: models_manager::manager::tests::{refresh_available_models_*}, shell_snapshot::tests::linux_sh_snapshot_includes_sections, exec::tests::kill_child_process_group_kills_grandchildren_on_timeout)

View task →

@aibrahim-oai

Copy link
Copy Markdown
Contributor Author

@codex review this

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

Copy link
Copy Markdown
Contributor

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: de6149c4bc

ℹ️ 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/core/src/codex.rs Resolved
@aibrahim-oai aibrahim-oai changed the title Handle reasoning-included header Reset reasoning-included per turn Jan 17, 2026
@aibrahim-oai aibrahim-oai changed the title Reset reasoning-included per turn Act on reasoning-included per turn Jan 17, 2026
@aibrahim-oai

Copy link
Copy Markdown
Contributor Author

@codex review this

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

Copy link
Copy Markdown
Contributor

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: 51a67b00f8

ℹ️ 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 on lines 67 to +71
tokio::spawn(async move {
if server_reasoning_included {
let _ = tx_event
.send(Ok(ResponseEvent::ServerReasoningIncluded(true)))
.await;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Avoid caching reasoning header across websocket turns

ServerReasoningIncluded is described as being emitted when the header is present on that response, but here the websocket path captures the header once at connect time and reuses it for every stream_request. Because the same websocket connection is reused across turns, the flag can never clear on later turns if the server omits X-Reasoning-Included for a subsequent response, so server_reasoning_included stays true and get_total_token_usage will undercount (skipping the extra reasoning tokens) until the connection is torn down. Consider re-checking per request (or reconnecting per turn) so the flag can clear when the header is absent.

Useful? React with 👍 / 👎.

@aibrahim-oai
aibrahim-oai merged commit b11e96f into main Jan 19, 2026
@aibrahim-oai
aibrahim-oai deleted the reasoning-included branch January 19, 2026 19:23
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 19, 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