Repository navigation
fix(agent): refuse to execute tool calls from non-completed responses - #177
Merged
alexb-openrouter merged 1 commit intoDec 1, 2026
Merged
Conversation
Contributor
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
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
Previously,
responseHasToolCallsandextractToolCallsFromResponseinpackages/agent/src/lib/stream-transformers.tsonly refused tool execution whenresponse.status === 'incomplete'andresponse.incompleteDetails?.reason === 'max_output_tokens'. Responses with any other non-completed status —failed,cancelled,in_progress,queued, orincompletedue tocontent_filter(or missing details) — could still execute local tools if theiroutputcontainedfunction_callitems.Changes
packages/agent/src/lib/stream-transformers.ts: ReplaceisTruncatedAtMaxOutputTokenswithisResponseCompleted(response.status === 'completed'). BothresponseHasToolCallsandextractToolCallsFromResponsenow returnfalse/[]for any response whose status is not'completed'.packages/agent/src/lib/conversation-state.ts: GuardextractToolCallsFromResponsewithresponse.status !== 'completed'for parity with the stream-transformer extractor.packages/agent/tests/unit/non-completed-response-tool-calls.test.ts: Add unit tests coveringfailed,cancelled,incomplete(content_filter,max_output_tokens, andnulldetails),in_progress, andqueuedresponses across the extractors,callModel(initial turn, streamingresponse.incompleteand mismatchedresponse.completed, and follow-up turn withstopWhen+allowFinalResponse), andexecuteToolLoop, plus acompletedcontrol case.status: 'completed'to five unit test fixture helpers that previously omittedstatusviaas unknown as models.OpenResponsesResult.Testing
pnpm test(@openrouter/agent: 113 files, 1318 tests;@openrouter/mcp: all unit tests passing)pnpm typecheckpnpm lintpnpm buildpnpm verify:packages