Skip to content

fix: preserve non-ASCII tool result text#2653

Open
cyphercodes wants to merge 1 commit into
strands-agents:mainfrom
cyphercodes:agent-tasks/2636
Open

fix: preserve non-ASCII tool result text#2653
cyphercodes wants to merge 1 commit into
strands-agents:mainfrom
cyphercodes:agent-tasks/2636

Conversation

@cyphercodes

@cyphercodes cyphercodes commented Jun 6, 2026

Copy link
Copy Markdown

Description

@tool results returned as dictionaries or lists currently escape CJK and emoji characters because the standard JSON serializer defaults to ASCII escaping, while Pydantic model returns keep UTF-8 text. This keeps structured tool-result text human-readable regardless of whether a tool returns a dict, list, or model.

Related Issues

Resolves #2636

Documentation PR

No documentation changes are needed for this bug fix.

Type of Change

Bug fix

Testing

  • uv run --extra dev pytest tests/strands/tools/test_decorator.py -vv

  • uv run --extra dev ruff format --check src/strands/tools/decorator.py tests/strands/tools/test_decorator.py

  • uv run --extra dev ruff check src/strands/tools/decorator.py tests/strands/tools/test_decorator.py

  • uv run --extra dev mypy src/strands/tools/decorator.py

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • Documentation changes are not needed for this bug fix
  • No new docs example is needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published, or are not needed

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@yatszhash

Copy link
Copy Markdown
Contributor

Thanks for fixing the decorator path here! 🙏

Heads-up on scope: the provider-side json.dumps escaping that #2636 also listed — tool-result {"json": ...} content blocks and tool-call argument serialization across Anthropic / OpenAI-family providers (hit in practice by e.g. multi-agent / agent-as-tool structured output) — isn't covered by this PR. I've split it into #2660 and opened PR #2661 for it.

This PR's Resolves #2636 is fine to keep — #2660 tracks the provider-side remainder independently.

@yonib05 yonib05 added bug Something isn't working python Pull requests that update python code area-tool Tool behavior/api labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-tool Tool behavior/api bug Something isn't working python Pull requests that update python code size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Tool results with non-ASCII text are serialized inconsistently — dict returns are \uXXXX-escaped, Pydantic models are not

3 participants