Skip to content

fix(claude): bound streamed reasoning identity - #1377

Merged
Wibias merged 1 commit into
lidge-jun:devfrom
luvs01:agent/bound-reasoning-part-key
Aug 10, 2026
Merged

fix(claude): bound streamed reasoning identity#1377
Wibias merged 1 commit into
lidge-jun:devfrom
luvs01:agent/bound-reasoning-part-key

Conversation

@luvs01

@luvs01 luvs01 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace retained raw reasoning item_id and part-index strings with fixed-size SHA-256 identities.
  • Preserve same-item/same-part equality and distinct item/part \n\n boundaries, including malformed string and array metadata, instead of collapsing all invalid identities to one sentinel.
  • Keep ordinary numeric protocol indexes compact and add large-identity and malformed-array regressions.

Verification

  • Bun 1.3.14: bun test tests/claude-outbound.test.ts — 38 passed.
  • bun run typecheck — passed.
  • bun run privacy:scan — passed.
  • git diff --check HEAD^ HEAD — passed.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • No documentation change is required for this internal stream-state hardening.
  • The branch is based on the latest dev.

Review readiness checklist

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of reasoning summaries with very large or malformed identifiers.
    • Preserved distinct thinking blocks when item and part identities differ.
    • Prevented oversized upstream values from affecting reasoning metadata boundaries.
  • Tests

    • Added regression coverage for large identifiers and malformed values.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

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

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently. If no CodeRabbit review appears, comment @coderabbitai review to request one.
Maintainers: @lidge-jun @Ingwannu @Wibias

Wibias commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Please rebase this PR onto the latest dev (e8ce2b93dd3ef8074d96dee407704c5dc06e2699) before merge, then rerun the exact-head CI checks.

@luvs01
luvs01 force-pushed the agent/bound-reasoning-part-key branch from 3ca029b to 6087441 Compare August 9, 2026 23:25
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c7608e86-99da-4408-80db-6f6bd4734541

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The Claude outbound path now creates bounded SHA-256 identities for reasoning metadata. Thinking-block keys preserve item and part distinctions without retaining large upstream values. Tests cover large, repeated, changed, and malformed identities.

Changes

Reasoning identity boundaries

Layer / File(s) Summary
Bounded identity construction
src/claude/outbound.ts
Adds fixed-size identity helpers for reasoning metadata and uses them in thinking-block keys while preserving item and part distinctions.
Identity boundary regression coverage
tests/claude-outbound.test.ts
Tests large identifiers, repeated identities, changed identities, and malformed array-valued identities.

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

Possibly related PRs

Suggested reviewers: lidge-jun, wibias, ingwannu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: bounding streamed Claude reasoning identities.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@Wibias
Wibias marked this pull request as ready for review August 9, 2026 23:45
@luvs01

luvs01 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor
✅ 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.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

@github-actions[bot] have exceeded the limit for the number of chat messages per hour. Please wait 48 minutes and 28 seconds before sending another message.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== PR metadata =='
gh pr view 1377 --repo lidge-jun/opencodex --json number,headRefOid,baseRefOid,commits,title,url

echo '== Changed files and diff =='
git diff --find-renames origin/dev...HEAD -- src/claude/outbound.ts tests/claude-outbound.test.ts

echo '== Source outline =='
ast-grep outline src/claude/outbound.ts --items all --view expanded

echo '== Relevant source references =='
rg -n -C 5 -e 'thinking|reasoning|summary_index|item_id|createHash|sha256' src/claude/outbound.ts

echo '== Relevant test references =='
rg -n -C 8 -e 'thinking|reasoning|summary_index|item_id|large|malformed' tests/claude-outbound.test.ts

Length of output: 1654


🏁 Script executed:

#!/bin/bash
set -u

echo '== PR diff from GitHub =='
gh pr diff 1377 --repo lidge-jun/opencodex -- src/claude/outbound.ts tests/claude-outbound.test.ts || true

echo '== Source outline =='
ast-grep outline src/claude/outbound.ts --items all --view expanded || true

echo '== Relevant source references =='
rg -n -C 7 -e 'thinking|reasoning|summary_index|item_id|createHash|sha256' src/claude/outbound.ts || true

echo '== Relevant test references =='
rg -n -C 10 -e 'thinking|reasoning|summary_index|item_id|large|malformed' tests/claude-outbound.test.ts || true

Length of output: 39555


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== Changed-file patches =='
gh api --paginate 'repos/lidge-jun/opencodex/pulls/1377/files?per_page=100' \
  --jq '.[] | select(.filename == "src/claude/outbound.ts" or .filename == "tests/claude-outbound.test.ts") | "FILE: \(.filename)\n\(.patch)\n"'

echo '== Streaming parser and budget context =='
sed -n '218,410p' src/claude/outbound.ts

echo '== SSE decoding and payload handling references =='
rg -n -C 6 -e 'JSON\.parse|sseFieldValue|translatorBudget|reserve|replaceRetained' src/claude/outbound.ts src/lib/sse-decoder.ts src/lib/translator-budget.ts

Length of output: 66764


@github-actions[bot] I reviewed the current PR head 6087441bded742e3bc9ec813ba6628fa640c2874.

I found no correctness issue in the reviewed change.

src/claude/outbound.ts Lines 28-46 creates bounded identities for strings and arrays. Lines 388-401 preserve \n\n boundaries when the reasoning item or part changes.

tests/claude-outbound.test.ts Lines 309-360 cover large string identities and distinct malformed array identities.

I did not execute repository tests in this review. The readiness gate reports that all required checks passed.

⚠️ Action not completed

Already reviewed.

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.

@Wibias
Wibias merged commit 8667e09 into lidge-jun:dev Aug 10, 2026
31 of 35 checks passed

Wibias commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks @luvs01 — nice stream-state hardening. Hashing oversized reasoning identities keeps the equality/boundary semantics intact without retaining attacker-sized metadata, and the malformed-identity regressions cover the tricky cases well. 🙏

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

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants