Skip to content

Preserve provider reasoning and Codex summaries in buffered responses - #120

Merged
jmlago merged 3 commits into
mainfrom
feat/agent-io-traces
Sep 21, 2026
Merged

jmlago merged 3 commits into
mainfrom
feat/agent-io-traces

Conversation

@acastellana

@acastellana acastellana commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Buffered responses discarded reasoning fields returned by providers, preventing downstream agents from capturing their complete response. Preserve provider-exposed reasoning and usage in buffered chat, including stream-backed aggregation, and retain Codex summaries and opaque reasoning items in chat and Responses output.

  • Forward explicit Codex reasoning effort/summary controls through the existing OAuth backend. No new authentication flow or default reasoning enablement.
  • Keep truly empty responses eligible for fallback. Empty/whitespace reasoning and metadata-only details do not satisfy the first-output deadline; nonempty summaries, text and opaque payloads remain intact.
  • Replay Responses reasoning items and summary events before subsequent message/tool items, with contiguous output indexes and increasing sequence numbers.
  • Keep response content out of bounded diagnostics and operational ledger summaries. Tests verify both preservation in the response and exclusion from diagnostics.

Validation: 152 focused tests passed locally, including empty-response/deadline regressions and reconstruction of the actual /v1/responses SSE output. Full CI on 4c2364b: 1,131 Python tests passed (2 skipped), 729 core tests passed, and both images built with startup/import smoke checks passing. CI run. Branch includes current main and the PR119 probability-rounding fix.

Scope: upstream providers are mocked in tests; no live provider/OAuth request or deployment performed. Public chat reasoning deltas, native non-compatible adapters and downstream trace persistence remain outside this change. Compatible SSE reasoning-details fragments are preserved as received; failed Codex streams may still discard partial summaries. This preserves only provider-exposed data, not hidden internal reasoning.

Rollback: revert this PR; no database or configuration migration.

Summary by CodeRabbit

  • New Features

    • Provider reasoning summaries are now preserved in buffered and streaming chat responses.
    • Reasoning-only responses are supported without being treated as empty assistant messages.
    • Responses API streams reasoning items and summary events before subsequent text or tool-call output.
    • Reasoning token usage is included when provided by the upstream model.
    • Codex reasoning controls, including effort and summary settings, are forwarded.
  • Documentation

    • Added documentation covering reasoning behavior, supported controls, usage reporting, and scope limitations.

@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 4fef68a6-5f0e-478e-bc5a-abf853e86702

📥 Commits

Reviewing files that changed from the base of the PR and between a045d19 and 4c2364b.

📒 Files selected for processing (9)
  • README.md
  • codex_backend.py
  • provider_adapters/openai_compatible.py
  • responses_api.py
  • shim.py
  • tests/test_provider_diagnostics.py
  • tests/test_reasoning_capture.py
  • tests/test_responses_api.py
  • tests/test_responses_shim.py
 ________________________________________________
< PENDU: Prompt Engineered Nifty Debugging Unit. >
 ------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jmlago
jmlago marked this pull request as ready for review September 21, 2026 09:11
@jmlago
jmlago merged commit bfb99a1 into main Sep 21, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants