Skip to content

Python: fix(anthropic): nest bash tool result files inside the shell tool result - #9343

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
ManoharPaturi:fix/anthropic-bash-files
Oct 15, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
ManoharPaturi:fix/anthropic-bash-files

Conversation

@ManoharPaturi

Copy link
Copy Markdown
Contributor

Motivation & Context

When the Anthropic Messages API returns a bash_code_execution_tool_result block with hosted output files, _parse_contents_from_anthropic put the files on the message-level contents list instead of the shell result's outputs. The files showed up as bare top-level hosted_file contents next to the shell_tool_result, and anything iterating tool result outputs lost them. Issue #9342 has the repro.

Description & Review Guide

  • What are the major changes? The bash branch now appends its file contents to shell_outputs, the same way the code_execution_tool_result branch appends to code_outputs.
  • What is the impact of these changes? Bash tool result files land inside the shell_tool_result outputs. No other branch changes.
  • What do you want reviewers to focus on? The one-line target change and the new test.

Related Issue

Fixes #9342

AI Assistance

  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

…tool result

The bash branch appended hosted output files to the message-level
contents list instead of the shell result outputs, so the files leaked
out as bare top-level hosted_file contents. The code interpreter twin
branch already nested them correctly.

Fixes microsoft#9342

Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
@ManoharPaturi

Copy link
Copy Markdown
Contributor Author

Typing check was right, the new test iterated outputs without the None guard the sibling tests use. Added the guard and pushed 4e99954.

Merged via the queue into microsoft:main with commit d95defa Oct 15, 2026
45 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 4e999542 Deployed Oct 14, 2026 by ManoharPaturi via add_label #25259
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: anthropic bash tool result files leak out of the shell tool result

2 participants