| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Beta built-in tools for the Microsoft Agent Framework. A home for first-party Python tools that plug into any chat client's shell / function surface. The first tool is LocalShellTool.
pip install agent-framework-tools --preimport asyncio
from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient
from agent_framework.tools import LocalShellTool
async def main() -> None:
client = OpenAIChatClient(model="gpt-5.4-nano")
async with LocalShellTool() as shell:
agent = Agent(
client=client,
instructions="You are a helpful assistant that can run shell commands.",
tools=[client.get_shell_tool(func=shell.as_function())],
)
result = await agent.run("Print the current working directory.")
print(result.text)
asyncio.run(main())LocalShellTool is not a sandbox. It runs commands directly on the host with the agent process's privileges. The actual security boundary is approval-in-the-loop. For untrusted input use a sandboxed executor — see agent-framework-hyperlight.
Defenses (in priority order):
Override with ShellPolicy:
from agent_framework.tools import LocalShellTool, ShellPolicy
shell = LocalShellTool(
policy=ShellPolicy(allowlist=[r"^ls\b", r"^cat\b", r"^git status$"]),
approval_mode="never_require",
acknowledge_unsafe=True, # required to bypass approval
)A model talking to a PowerShell session will sometimes default to bash syntax (export FOO=bar, ls -la, > /dev/null) and vice versa. ShellEnvironmentProvider is an AIContextProvider that probes the live shell once per session — family, version, OS, working directory, and a configurable list of CLI tools (git, node, python, docker by default) — and injects a system-prompt block describing the shell idiom to use and the available CLIs.
from agent_framework.tools import (
LocalShellTool,
ShellEnvironmentProvider,
ShellEnvironmentProviderOptions,
)
shell = LocalShellTool()
provider = ShellEnvironmentProvider(
shell,
ShellEnvironmentProviderOptions(probe_tools=("git", "uv", "node")),
)
agent = Agent(
client=client,
tools=[client.get_shell_tool(func=shell.as_function())],
context_providers=[provider],
)Probe failures from expected error types (timeouts, policy rejections, spawn failures) are recorded as None fields in the snapshot rather than raised; a missing CLI never fails the agent. A failed first probe does not poison the cache — the next call retries.
When commands originate from untrusted input (e.g. the model is acting on prompt-injected document content), prefer DockerShellTool. With the default isolation flags and a trusted container runtime, the container is the intended security boundary and approval gating becomes optional.
import asyncio
from agent_framework.tools import DockerShellTool
async def main() -> None:
async with DockerShellTool(
image="mcr.microsoft.com/azurelinux/base/core:3.0",
approval_mode="never_require", # container is the boundary
) as shell:
result = await shell.run("uname -a && id")
print(result.stdout)
asyncio.run(main())Defaults applied to every container:
To expose a host directory, pass host_workdir="/path" (mounted read-only by default; mount_readonly=False to allow writes). Swap the container runtime with docker_binary="podman".
| Use case | Tool | Sandbox |
|---|---|---|
| Run code (untrusted) | HyperlightCodeActProvider.execute_code (agent-framework-hyperlight) | Hyperlight WASM microVM |
| Run shell (untrusted) | DockerShellTool | OCI container (network-off, non-root, capabilities dropped) |
| Run shell (trusted dev) | LocalShellTool | Approval-in-the-loop |
agent-framework-hyperlight is a code sandbox (a single WASM guest loaded into a microVM, called via a hostcall ABI — there is no kernel, userland, or shell binary inside). It is the right tier for executing generated code. For sandboxing shell commands, the realistic tier is OCI, which DockerShellTool provides.
| Back | FazBrowse Home | New Git URL |