Skip to content

[WRONG BRANCH] fix(responses): prevent cross-request reasoning replay - #37

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-global-reasoning-replay-cache-leak
Draft

[WRONG BRANCH] fix(responses): prevent cross-request reasoning replay#37
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-global-reasoning-replay-cache-leak

Conversation

@luvs01

@luvs01 luvs01 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Motivation

  • The in-process reasoning replay cache could leak hidden assistant reasoning across unrelated requests when a tool call ID collided or was unscoped, risking disclosure and context poisoning.
  • Call IDs are provider/client-controlled and not globally unique, so the cache must not fall back to a process-wide namespace.

Description

  • Require an explicit conversation scope for cache operations and stop using a global fallback by making rememberReasoningForCall and peekReasoningForCall fail closed when scope is absent, and key entries with scope + '\u0000' + callId (changes in src/responses/reasoning-replay-cache.ts).
  • Remove the implicit "global" replayCacheScope fallback and propagate only the explicit client thread id (parsed._clientThreadId) through the bridge, adapters, image loop, and web-search loop (changes in src/bridge.ts, src/adapters/openai-chat.ts, src/images/loop.ts, src/web-search/loop.ts, and src/server/responses/core.ts).
  • Update tests to exercise scoped behaviour and assert that unscoped cache reads/writes are rejected, and adapt existing replay tests to set a test REPLAY_SCOPE (changes in tests/deepseek-reasoning-replay-gaps.test.ts and tests/bridge-raw-reasoning-hidden.test.ts).

Testing

  • Ran the focused regressions: bun test tests/deepseek-reasoning-replay-gaps.test.ts tests/bridge-raw-reasoning-hidden.test.ts and the modified tests passed (23/23 in those runs).
  • Ran full project checks: bun run typecheck, bun run test, and bun run privacy:scan, all of which completed successfully.
  • Verified repository hygiene with git diff --check and a clean working tree after the changes.

Summary by CodeRabbit

  • Bug Fixes

    • Improved reasoning replay-cache isolation by requiring an explicit conversation scope.
    • Prevented requests without a conversation identifier from sharing or accessing globally scoped cached reasoning.
    • Updated streaming, batch, image, and web-search flows to preserve conversation-specific cache boundaries.
  • Tests

    • Expanded coverage for scoped replay caching, including isolation and unscoped-access scenarios.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: dd7b1786-3097-488b-90a5-8868d5d5cb37

📥 Commits

Reviewing files that changed from the base of the PR and between 2468502 and d7b98d8.

📒 Files selected for processing (8)
  • src/adapters/openai-chat.ts
  • src/bridge.ts
  • src/images/loop.ts
  • src/responses/reasoning-replay-cache.ts
  • src/server/responses/core.ts
  • src/web-search/loop.ts
  • tests/bridge-raw-reasoning-hidden.test.ts
  • tests/deepseek-reasoning-replay-gaps.test.ts

📝 Walkthrough

Walkthrough

The change removes the "global" reasoning replay-cache fallback. Cache reads and writes now require an explicit client thread scope. Response paths and tests pass explicit scopes and verify isolation.

Changes

Reasoning replay-cache scoping

Layer / File(s) Summary
Require explicit cache scopes
src/responses/reasoning-replay-cache.ts
keyFor, rememberReasoningForCall, and peekReasoningForCall no longer use or accept missing scopes.
Propagate client thread scopes
src/adapters/openai-chat.ts, src/server/responses/core.ts, src/bridge.ts, src/images/loop.ts, src/web-search/loop.ts
Response and tool paths pass _clientThreadId directly. Requests without a client thread ID leave replayCacheScope undefined.
Validate scoped cache behavior
tests/bridge-raw-reasoning-hidden.test.ts, tests/deepseek-reasoning-replay-gaps.test.ts
Tests use explicit test scopes and verify that unscoped cache entries are rejected and cannot be retrieved.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: wibias, lidge-jun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preventing cross-request reasoning replay; the branch marker adds minor noise but does not make the title misleading.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-global-reasoning-replay-cache-leak

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

@github-actions github-actions Bot changed the title fix(responses): prevent cross-request reasoning replay [WRONG BRANCH] fix(responses): prevent cross-request reasoning replay Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft August 7, 2026 07:31
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 7, 2026
@luvs01

luvs01 commented Aug 7, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant