Repository navigation
fix(agent): send the json value returned by to_model_output instead of the raw tool result - #37
Merged
alexb-openrouter merged 3 commits intoNov 23, 2026
Conversation
…f the raw tool result
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
Risk: a tool whose
to_model_outputreturns{"type": "json", "value": ...}(for example, to drop private fields before the model sees them) had that value ignored. The SDK sent the full raw tool result to the model instead, so anything the converter meant to hide reached model context.ToModelOutputResult.typeis declared asLiteral["content", "json"], butModelResult._tool_result_to_outputonly honored"content"; every other result fell through tojson_dumps(result["result"]).if isinstance(converted, Mapping) and converted.get("type") == "content": output = converted.get("value", []) +elif isinstance(converted, Mapping) and converted.get("type") == "json": + output = json_dumps(converted.get("value")) else: output = json_dumps(result.get("result"))tests/unit/test_to_model_output_json.pyruns a tool that returns a private field, redacts it with sync and asyncjsonconverters, and asserts the follow-upfunction_call_outputholds only the converter's value. Bothjsontests fail onmain(the private value appears in the output) and pass with the fix; thecontentpath is covered to guard against regressions.Local:
ruff check .,ruff format --check .,mypy src tests,pytest tests/unit(145 passed).Note for the upstream port: the TypeScript
toModelOutputtype only allowscontent, so a sync should keep thisjsonbranch.