-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Python: Added ShellTool and LocalShellExecutor #3309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will we include any sample code on how to use this?
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