Open
Conversation
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request implements shell command execution capabilities for the Agent Framework across OpenAI and Anthropic providers. The implementation adds a new ShellTool class that extends FunctionTool, along with shell-specific content types for structured representation of command execution and results. The PR enables both hosted shell execution (in OpenAI's managed containers) and local shell execution (on the developer's machine) with provider-specific API mappings.
Changes:
- Introduced
ShellToolclass and@shell_tooldecorator for creating shell command execution tools with provider-specific configuration support viaadditional_properties - Added three shell content types (
shell_tool_call,shell_tool_result,shell_command_output) with factory methods and serialization support - Implemented OpenAI Responses API integration with
get_hosted_shell_tool()for managed container execution and parsing logic for shell_call/shell_call_output - Integrated Anthropic bash tool support by detecting
ShellToolinstances and mapping them tobash_20250124API format, with updated result parsing to use shell content types - Provided three sample implementations demonstrating OpenAI hosted shell, OpenAI local shell with user confirmation, and Anthropic local shell execution
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
python/packages/core/agent_framework/_tools.py |
Adds ShellTool class extending FunctionTool and @shell_tool decorator with overloads for convenient shell tool creation |
python/packages/core/agent_framework/_types.py |
Adds shell content type definitions (shell_tool_call, shell_tool_result, shell_command_output) with factory methods and serialization support |
python/packages/core/agent_framework/__init__.py |
Exports ShellTool and shell_tool to public API |
python/packages/core/agent_framework/_agents.py |
Reformats ternary expression for improved readability (formatting only) |
python/packages/core/agent_framework/openai/_responses_client.py |
Implements get_hosted_shell_tool() method and parsing logic for shell_call and shell_call_output in both sync and streaming modes |
python/packages/anthropic/agent_framework_anthropic/_chat_client.py |
Adds ShellTool detection in _prepare_tools_for_anthropic() to map to bash API format, updates bash result parsing to use shell content types instead of generic function_result |
python/packages/core/tests/core/test_types.py |
Adds comprehensive tests for shell content type creation, properties, and serialization roundtrip |
python/packages/core/tests/openai/test_openai_responses_client.py |
Adds tests for get_hosted_shell_tool() and shell_call/shell_call_output parsing including timeout scenarios |
python/packages/anthropic/tests/test_anthropic_client.py |
Adds tests for ShellTool to Anthropic bash format conversion and updates bash result parsing tests to verify shell content types, including error handling |
python/packages/core/tests/workflow/test_workflow_kwargs.py |
Formatting change to fit long line within reasonable length (formatting only) |
python/packages/core/tests/workflow/test_agent_executor.py |
Formatting change to fit function signature on one line (formatting only) |
python/samples/02-agents/providers/openai/openai_responses_client_with_shell.py |
Sample demonstrating OpenAI hosted shell tool with managed container execution |
python/samples/02-agents/providers/openai/openai_responses_client_with_local_shell.py |
Sample demonstrating local shell execution with OpenAI, including user confirmation prompts |
python/samples/02-agents/providers/anthropic/anthropic_with_shell.py |
Sample demonstrating local shell execution with Anthropic bash tool, including user confirmation prompts |
python/samples/02-agents/providers/openai/openai_responses_client_with_local_shell.py
Show resolved
Hide resolved
…ent-framework into python-shell-tool
- Add shell_tool_call, shell_tool_result, and shell_command_output content types - Add ShellTool class and shell_tool decorator to core - Add get_hosted_shell_tool() to OpenAI Responses client - Handle shell_call and shell_call_output parsing in OpenAI (sync and streaming) - Map ShellTool to Anthropic bash tool API format - Parse bash_code_execution_tool_result as shell_tool_result in Anthropic - Add unit tests for all new functionality - Add sample scripts for hosted and local shell execution Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Contribution Checklist