Python: Flatten hyperlight execute_code output#5333
Merged
eavanvalkenburg merged 2 commits intomicrosoft:mainfrom Apr 20, 2026
Merged
Python: Flatten hyperlight execute_code output#5333eavanvalkenburg merged 2 commits intomicrosoft:mainfrom
eavanvalkenburg merged 2 commits intomicrosoft:mainfrom
Conversation
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Hyperlight execute_code tool output shape so stdout/files/errors are returned as a flat list of Content items, ensuring Content.from_function_result can populate .result (and rich .items) correctly for downstream clients.
Changes:
- Flatten
_build_execution_contentsto returnlist[Content]directly (nocode_interpreter_tool_resultwrapper). - Preserve user-provided
result_parserin_make_sandbox_callback(only default to passthrough when unset). - Update CodeAct instructions to include filesystem-aware output guidance; update tests and samples for the flattened output shape; add a new benchmark sample.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| python/packages/hyperlight/agent_framework_hyperlight/_execute_code_tool.py | Flattens execute_code outputs and adjusts sandbox callback result_parser behavior. |
| python/packages/hyperlight/agent_framework_hyperlight/_instructions.py | Adds filesystem-aware guidance and encourages print(...) for surfacing results. |
| python/packages/hyperlight/tests/hyperlight/test_hyperlight_codeact.py | Updates assertions/helpers to consume flattened tool outputs. |
| python/packages/hyperlight/samples/codeact_context_provider.py | Updates sample logging to iterate flattened execute_code results. |
| python/packages/hyperlight/samples/codeact_benchmark.py | Adds a new sample comparing traditional tool-calling vs CodeAct. |
moonbox3
approved these changes
Apr 20, 2026
westey-m
approved these changes
Apr 20, 2026
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 and Context
Hyperlight's
execute_codetool previously wrapped its stdout/file outputs in a singlecode_interpreter_tool_resultcontent item.Content.from_function_resultonly collects text from top-level items, so the nested text never made it intofunction_result.result, which meant the OpenAI Responses client (and any other client that reads.result) sent an empty string to the model even though the data was available onitems.Description
_build_execution_contentsto return the output list directly (text + data + error contents), removing thecode_interpreter_tool_resultwrapper. Keeps the fix isolated to the hyperlight package - no core changes needed.result_parserin_make_sandbox_callback; only auto-assign the passthrough parser when none is set.build_codeact_instructionsaboutfilesystem_enabledand add guidance toprint(...)at the end of code and use/output/<file>for larger artifacts.codeact_context_providersample to consume the flattened output shape.codeact_benchmarksample underpackages/hyperlight/samples/that compares traditional tool-calling and CodeAct side-by-side withFoundryChatClient(timing + token counts + structured output).