Repository navigation
fix(opencode): do not read a tracked tool part for each streamed input delta - #1
Merged
Merged
Conversation
…t delta Every tool-input-delta and tool-input-end went through ensureToolCall, which reads the stored part back: one database round trip per streamed chunk of a tool call's arguments, though neither event writes anything. A 10k-token document edit in production produced about 10,200 reads in 93 seconds. A call already in ctx.toolcalls has its part from tool-input-start, so those events now only create one when it is missing. The test streams 2,000 deltas (2,004 reads before, under 10 after) and also pins that a tool's error text reaches the model unchanged, as an error-text tool result. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 72 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A DocuMentor production bug report (2026-10-08 16:52, "the chat says it will revise the workspace and doesn't") led to a 93-second, 10,248-token
propose_document_changescall. While it streamed, Jaeger recorded about 10,200SessionProcessor.readToolCall/Session.getPartspans and 10,400sql.executespans for that one session: everytool-input-deltagoes throughensureToolCall, which reads the stored part back, though the delta writes nothing. Upstream reads a local SQLite file; on this branch each read is a Postgres round trip.What
processor.ts:tool-input-deltaandtool-input-endcallensureToolCallonly for a call not yet inctx.toolcalls(its part exists fromtool-input-start).test/pg/processor-tool-call.test.ts: streams 2,000 deltas and countsgetPartcalls — 2,004 before, under 10 after. It also pins the other half of the report: a tool's error text (here kpg-agent-tools' refusal of overlapping proposals) is stored whole and reaches the model as{ type: "error-text", value: <full text> }.documentor/FORK.md: theprocessor.tsrow.Verification
Local, Postgres 18 (
C.UTF-8): the new test, andtest/session/in full (419 pass, 0 fail, 8 skip);bun run typecheckclean.No release tag: publishing an image is a separate, operator-approved step.
🤖 Generated with Claude Code