fix(smolagents): combine multiple text content blocks from MCP tools - #84
Open
syf2211 wants to merge 1 commit into
Open
fix(smolagents): combine multiple text content blocks from MCP tools#84syf2211 wants to merge 1 commit into
syf2211 wants to merge 1 commit into
Conversation
When an MCP tool returns multiple TextContent blocks, SmolAgentsAdapter previously logged a warning and returned only the first block. Join all text blocks with newlines so agents receive the full tool output. Fixes grll#67
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 an MCP tool returns multiple
TextContentblocks,SmolAgentsAdapterpreviously logged a warning and returned only the first block. This change joins all text blocks with newlines so agents receive the full tool output.Motivation
Fixes #67. Users wrapping MCP servers that emit multiple text parts (e.g. GraphQL introspection schemas split across blocks) were silently losing data beyond the first content item.
Changes
_combine_text_contents()helper insmolagents_adapter.pyMCPAdaptTool.forward(), combine all-text multi-block responses instead of using onlycontent[0]test_multiple_text_content_blocks_are_combinedTests
uv run --extra test pytest tests/test_smolagents_adapter.py -q→ 10 passeduv run ruff check src/mcpadapt/smolagents_adapter.py tests/test_smolagents_adapter.py→ passedNotes
TextContentblocks are now returned together (newline-separated) instead of first-only.