Python: Added ShellTool and LocalShellExecutor#3309
Closed
dmytrostruk wants to merge 24 commits intomicrosoft:mainfrom
Closed
Python: Added ShellTool and LocalShellExecutor#3309dmytrostruk wants to merge 24 commits intomicrosoft:mainfrom
dmytrostruk wants to merge 24 commits intomicrosoft:mainfrom
Conversation
Member
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds shell command execution capabilities to the Agent Framework through a new ShellTool abstraction and LocalShellExecutor implementation.
Changes:
- Introduces
ShellToolwith comprehensive security validation (privilege escalation blocking, dangerous pattern detection, path restrictions) - Adds
LocalShellExecutorin newagent-framework-shell-localpackage using asyncio subprocess - Includes allowlist/denylist patterns, configurable timeouts, output truncation, and AI function conversion support
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python/uv.lock | Added agent-framework-shell-local package dependency |
| python/pyproject.toml | Registered new shell-local workspace package |
| python/packages/shell-local/pyproject.toml | Package configuration for shell-local with pytest, mypy, and bandit setup |
| python/packages/shell-local/agent_framework_shell_local/_executor.py | LocalShellExecutor implementation with async subprocess, timeout handling, and output truncation |
| python/packages/shell-local/agent_framework_shell_local/init.py | Package exports for LocalShellExecutor |
| python/packages/shell-local/README.md | Documentation covering installation, usage, security considerations, and configuration options |
| python/packages/shell-local/LICENSE | MIT license for the package |
| python/packages/shell-local/tests/test_executor.py | Comprehensive tests for LocalShellExecutor covering basic execution, timeouts, truncation, working directories, and stderr capture |
| python/packages/core/tests/core/test_shell_tool.py | Extensive tests for ShellTool validation, security patterns, path restrictions, and AI function conversion |
| python/packages/core/agent_framework/shell_local/init.pyi | Type stubs for lazy-loaded shell_local module |
| python/packages/core/agent_framework/shell_local/init.py | Lazy loading implementation for shell-local package |
| python/packages/core/agent_framework/_shell_tool.py | Core ShellTool implementation with security validation, pattern matching, and command execution |
| python/packages/core/agent_framework/init.py | Added shell_tool module to core exports |
moonbox3
reviewed
Jan 22, 2026
Contributor
moonbox3
left a comment
There was a problem hiding this comment.
Will we include any sample code on how to use this?
moonbox3
approved these changes
Jan 22, 2026
eavanvalkenburg
approved these changes
Jan 22, 2026
Member
|
I think this one still makes sense, just needs some work to move it to the new model with |
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
This PR adds shell command execution capabilities to the Agent Framework through a new
ShellToolabstraction andLocalShellExecutorimplementation.ShellToolabstraction for shell command execution with configurable security policiesLocalShellExecutorin newagent-framework-shell-localpackage usingasynciosubprocessas_ai_function()conversion for use with existing AI agentsContribution Checklist