Repository navigation
Conversation
…tput When structured_output is enabled, structuredContent was returned before checking CallToolResult.isError, so failures could look like successful empty results. Raise ValueError with text or structured error details before returning structured payloads. Fixes grll#94
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
When
SmolAgentsAdapter(structured_output=True)is used, failed MCP tool calls (isError=True) are no longer masked by returningstructuredContentthat looks like a successful result.Motivation
Fixes #94. MCP distinguishes tool execution errors via
isErrorand expects clients to surface those errors. The adapter returnedstructuredContentbefore checkingisError, so an error withstructuredContent={"results": []}was indistinguishable from a successful empty lookup.Changes
_tool_execution_error_message()to collectTextContenttext, or fall back tostructuredContent/ a generic message.MCPAdaptTool.forward(), raiseValueErrorwhenisErroris set, before the structured-content fast path.Tests
python3 -m pytest tests/test_smolagents_adapter.py::test_structured_output_raises_on_tool_execution_error -q→ 1 passedNotes
Uses
ValueErrorto match existing adapter error handling; smolagents wraps tool exceptions at the agent layer. Composer 2.5 review: APPROVE.