Repository navigation
fix(agent): send the json value returned by toModelOutput instead of the raw tool result - #173
Open
alexb-openrouter wants to merge 1 commit into
Open
alexb-openrouter wants to merge 1 commit into
alexb-openrouter wants to merge 1 commit into
Conversation
…the raw tool result
Contributor
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
alexb-openrouter
marked this pull request as ready for review
November 30, 2026 16:03
Contributor
This branch has not been deployed
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
computeToolOutputForModelonly used atoModelOutputresult when it hadtype: 'content'. Any other return, including{ type: 'json', value }, fell through toJSON.stringify(result), so the rawexecuteresult reached the model. A mapper written to hide fields had no effect. This matches the behavior the Python agent SDK already has forjson.Changes:
ToModelOutputResultadds{ type: 'json'; value: unknown }.computeToolOutputForModel:jsonreturnsJSON.stringify(value) ?? 'null'. Any other type throws instead of sending the raw result.unsentModelOutput(approval resume, auto-approved calls in a paused batch, background runs settled into unsent results): when the mapped output is the serializedjsonstring, it is parsed back sounsentResultsToAPIFormatserializes it once. Before, this path also returned the raw result for anything that was not a content array.Tests
tests/unit/to-model-output-json.test.tschecks that the raw value never appears in anyfunction_call_outputand that thejsonvalue does, for:graceMsAll 6 fail on
mainand pass with this change.pnpm run lint,pnpm run typecheckandpnpm run testpass.Not covered
Background results delivered after
graceMsas atool_task_resultenvelope (flushAsyncToolDeliveriesand the detached-run state write) embedtask.resultdirectly and never calltoModelOutputfor any type. That is a separate gap and is not changed here.