Skip to content

fix(anthropic): cap the server-tool input buffer on the incoming fragment - #7232

Closed
vadymhimself wants to merge 1 commit into
lidge-jun:devfrom
vadymhimself:fix/followup-srvtool-cap
Closed

vadymhimself wants to merge 1 commit into
lidge-jun:devfrom
vadymhimself:fix/followup-srvtool-cap

Conversation

@vadymhimself

@vadymhimself vadymhimself commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • CodeRabbit on fix: carry Claude translated-lane and usage-metering fixes (VB) #7225 (anthropic.ts server-tool input buffer): the guard checked only the existing length, so a single input_json_delta.partial_json over 4 KiB was appended whole and then retained and parsed.
  • The append now takes at most the remaining capacity. Past the cap the input loses its label (query / url), as the existing comment specifies, never the call.

Follow-up to the batch-2 bundle (#7224/#7225), which landed at a head from before this review finding was fixed on the source PR. The same commit was offered on the bundle.

Verification

  • Red on dev 7a42860 with only the new test: bun test tests/claude-integration/claude-translated-server-tools.test.ts gives 11 pass, 1 fail. A 5000-char fragment was kept whole and its query reached the client.
  • Green: 23 pass, 0 fail.
  • bun x tsc --noEmit: clean.
  • tests/test-layout.test.ts and tests/ci-workflows/file-size-ratchet.test.ts: pass.
  • Full suite not run locally; the change is confined to the files above and their focused tests.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

🤖 Generated with Claude Code

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when processing unusually large streamed search or fetch details. Search results and accompanying text continue to be delivered, while oversized query details are not included in the response.

…ment

A single input_json_delta fragment past 4 KiB was appended whole when the
buffer was empty, so the result handler retained and parsed input the cap
means to discard. Append at most the remaining capacity.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 73bb9cc9-9b94-45aa-9b06-18531c951717
📥 Commits

Reviewing files that changed from the base of the PR and between 7a42860 and b09cb35.

📒 Files selected for processing: 2
  • src/adapters/anthropic.ts
  • tests/claude-integration/claude-translated-server-tools.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The Anthropic adapter now limits accumulated JSON for streamed web_search and web_fetch results to 4096 characters. A regression test covers oversized search input and checks the resulting client block types and SSE response.

Changes: Anthropic server-tool input

Layer / File(s) Summary
Limit server-tool input
src/adapters/anthropic.ts, tests/claude-integration/claude-translated-server-tools.test.ts
The adapter appends at most 4096 characters across input fragments. The integration test checks that a 5000-character search input produces the expected client block types and that the query is absent from the SSE response.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: lidge-jun

Merge Risk: ⚪ Minimal · up to b09cb

Oversized server-tool input is bounded without disrupting search or fetch result delivery; no actionable merge risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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: limiting the server-tool input buffer for incoming Anthropic fragments.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

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

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

✅ READY

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

Review readiness checklist

  • ✅ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ✅ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ✅ 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.
Maintainers: @lidge-jun @Ingwannu

@vadymhimself

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@lidge-jun

Copy link
Copy Markdown
Owner

Being carried into #7236 with your authorship preserved; this PR will be closed when the bundle lands.

lidge-jun added a commit that referenced this pull request Oct 16, 2026
#7230, #7231, #7232, #7233) (#7236)

Carries four vadymhimself follow-ups onto dev:

- #7230: the combo sibling check peeks the round-robin ring without advancing it, while the failed account's cooldown is still recorded.
- #7231: a Codex account move after a 402 is recorded as quota recovery, separate from 429 rate recovery, through persistence, metrics, analytics and Logs labels.
- #7232: the Anthropic server-tool input buffer is capped on the incoming fragment (4,096 code units), so one oversized fragment cannot exceed the bound.
- #7233: refused-then-served usage rows are priced from the served attempt, and client cancels keep an unknown cost. A usage-less refusal never changes a row's pricing classification. A row with a leading refusal summarizes exactly like the same row without it, under dev's existing partial-cost contract.

Co-authored-by: Vadym O <bolein95@gmail.com>
@lidge-jun

Copy link
Copy Markdown
Owner

Landed on dev via #7236 in a02cecd, carried with Co-authored-by: Vadym O bolein95@gmail.com. That bundle is reviewed and validated (lidge full suite with 0 new failures, mini Windows focused 48/48, hosted CI green). #7233's pricing kept dev's existing partial-cost contract and pins refusal invariance. Details are on #7236. Thank you, @vadymhimself. Closing this one as superseded by that landing.

@lidge-jun lidge-jun closed this Oct 16, 2026
lidge-jun added a commit that referenced this pull request Oct 16, 2026
Preserve the incoming-fragment cap from #7232 while reconciling its regression and documentation with the approved rule that incomplete input drops the exchange. Resolve only the replay-owned documentation conflict.

Co-authored-by: Vadym O <bolein95@gmail.com>
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