Repository navigation
Python: preserve hosted tool results in ToolResultCompactionStrategy - #9887
Open
Kip (uragoodman) wants to merge 1 commit into
Open
Kip (uragoodman) wants to merge 1 commit into
Kip (uragoodman) wants to merge 1 commit into
Conversation
Handle shell, code interpreter, image generation, and computer tool results when collapsing old tool-call groups. Preserve status and timeout information, avoid embedding image payloads, and fall back to an explicit "no output returned" instead of "no results". Add regression tests for all four result types, status-only and timeout cases, mixed hosted results, multiple outputs/errors, and payload exclusion. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Kip (uragoodman)
requested review from
SergeyMenshykh,
Eduard van Valkenburg (eavanvalkenburg),
Roger Barreto (rogerbarreto) and
westey (westey-m)
as code owners
October 30, 2026 14:42
Kip (uragoodman)
temporarily deployed
to
github-app-auth
October 30, 2026 14:42 — with
GitHub Actions
Inactive
Kip (uragoodman)
requested review from
Darren Cohen (dargilco),
Jose Alvarez (jpalvarezl) and
sophia-ramsey
as code owners
October 30, 2026 14:42
3 tasks done
Kip (uragoodman)
had a problem deploying
to
github-app-auth
October 30, 2026 14:43 — with
GitHub Actions
Error
Author
|
@microsoft-github-policy-service agree |
This branch was successfully 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.
Motivation & Context
ToolResultCompactionStrategycollapses old tool-call groups into a shortsummary, but its result extraction only handles
function_result,mcp_server_tool_result, andsearch_tool_result. Groups containingshell_tool_result,code_interpreter_tool_result,image_generation_tool_result, orcomputer_tool_resultare still excluded,yet their summary says
[Tool results: no results]. The tool output is silentlylost from the compacted conversation.
This is reachable through
ContextWindowCompactionStrategy, which usesToolResultCompactionStrategyinternally, as well as by callers using thestrategy directly.
Based on upstream main at commit 4d4e216 (agent-framework-core 1.24.0).
Fixes #9886
The issue was filed with a complete reproduction. This PR is submitted
concurrently for early direction feedback; happy to adjust the approach or wait
if maintainers prefer to discuss the direction first.
Description & Review Guide
What are the major changes?
ToolResultCompactionStrategy._hosted_tool_result_summaryto render:base64 payloads;
no output returnedfallback instead ofno resultswhenthere is genuinely no result text.
mixed hosted results, multiple outputs/errors, original-message exclusion,
and payload exclusion.
What is the impact of these changes?
Only older tool-call groups containing these hosted result types change. The
function, MCP, and search paths are unchanged. No public API changes. Hosted
image payloads are represented by metadata (
media_type,file_id, orscreenshot) rather than copied into the summary.This PR intentionally scopes itself to
ToolResultCompactionStrategy.SummarizationStrategyhas a related rendering gap and is left for a separatefollow-up.
What do you want reviewers to focus on?
is acceptable, since these content types have no separate tool name.
explicit
no output returnedfallback are the right level of detail.AI Assistance
AI assistance details: an AI coding assistant helped with code-path analysis,
implementation, tests, and drafting this PR description. I reviewed and
verified the change and ran the focused tests below.
Contribution Checklist
pytest tests/core/test_compaction.py -q— 168 passed on Python 3.12.16.ruff check agent_framework/_compaction.py tests/core/test_compaction.pypasses with the repository-pinned Ruff 0.17.1.
ready-for-implementationlabel was present when this PR was opened; it is submitted for early direction feedback.