Fail the turn instead of dispatching truncated tool calls - #938
Merged
Conversation
TheGreatAxios
force-pushed
the
cl-7783-stop-reason-truncation
branch
from
September 12, 2026 05:04
3a38e2c to
0d60d81
Compare
TheGreatAxios
force-pushed
the
cl-7783-stop-reason-truncation
branch
from
September 12, 2026 05:35
0d60d81 to
980944c
Compare
Merged
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.
Summary
Fixes CL-7783: a truncated Anthropic tool_use (max_tokens cut off mid-JSON) was dispatched as a well-formed call —
{"_raw": ...}args or silently dropped params — and reached the reactor as a normal tool call. Now the adapter surfacesstop_reasonon the turn and end-of-stream finalization fails the turn with an actionable error instead of dispatching unparseable args.Changes
vendor/intx-inference/src/providers/anthropic.ts): parsestop_reasoninMessageDelta, plumb throughLastUsage/streamState, emit oninference.usage(arktype + static union invendor/intx-types/src/runtime.ts).vendor/intx-inference/src/harness.ts):finalizeStreamTurncollects parse failures across all three paths and throws aHarnessErrornaming the tool and failure kind (truncation vs malformed) instead of dispatching. No_rawfallback remains; the dead_rawconsumer insrc/plugins/path-escape-plugin.tsis removed.vendor/intx-inference/PATCHES.mdandvendor/intx-types/PATCHES.md;docs/VENDORING.mdupdated. Upstream untouched.Verification
content_block_starttool_use Bash, partialinput_json_delta,message_deltastop_reason: max_tokens,message_stop) and asserts notool_callblock reaches the reactor:bun test vendor/intx-inference/src/providers/anthropic.test.ts— 7 pass.inference-harness.test.ts,agent-tool-dispatch.test.ts) green;bun run checkgreen.Fixes CL-7783.