Agent Shell
Agent Shell is a light weight abstraction for executing a cli coding agent headlessly and returning the output that can be used programatically as a unified contractFeatures
- One unified contract — the same
execute,stream,health_check, andlist_modelsAPI across every agent; swap the backend without changing consuming code. - Seven CLI agents — Claude Code, OpenCode, Copilot CLI, Codex, Pi, Cursor, and Grok behind a common adapter protocol.
- Execute or stream — get one
AgentResponse(raisesAgentExecutionErroron a failed run), or async-iterate normalizedStreamEvents with optional thinking/reasoning. - Composable execution policy — preserve native execution by default, or opt into Linux PID namespace isolation without changing an agent adapter.
- Session resumption — continue any conversation by passing back its
session_id. - Normalized cost & tokens — consistent
costandoutput_tokens(reasoning included) regardless of how each CLI reports them. - Model discovery — retrieve the exact account/workspace-aware model strings accepted by each CLI, without inference calls, SDK dependencies, or static catalogs.
- Health checks — confirm an agent + model combination actually works before you rely on it, read from the event stream rather than unreliable exit codes.
- Portable tool control — one canonical allow/deny vocabulary
(
bash, edit, read, web_search, web_fetch) translated to each CLI's own tool names. - Unified MCP management — register, remove, and list MCP servers across agents through a single API.
- Package management — install/register, list, and remove harness packages through a shared API, with Pi as the first supported agent.
- Async & dependency-free — pure
asyncio, zero runtime dependencies, Python 3.12+.
Installation
uv add agent-shell-py
or with pip:
pip install agent-shell-py
Agent skills
The repository includes reusable skills that teach coding agents how to use AgentShell:
invoking-cli-agents— invoke, stream, resume, and restrict CLI agents.delegating-code-review— delegate an independent code review through AgentShell.
Install them interactively with the Vercel Skills CLI:
npx skills add ScottRBK/agent-shell
Or install both skills globally for every coding agent supported by AgentShell:
npx skills add ScottRBK/agent-shell --global \
--skill '*' \
--agent claude-code opencode github-copilot codex pi cursor grok \
--yes
Install only the core AgentShell skill with:
npx skills add ScottRBK/agent-shell --skill invoking-cli-agents
The skills provide agent instructions. Install agent-shell-py and the chosen coding-agent CLIs
separately.
Examples
Execute
from agent_shell.shell import AgentShell
from agent_shell.models.agent import AgentType
shell = AgentShell(agent_type=AgentType.CLAUDE_CODE)
response = await shell.execute(
cwd="/path/to/project",
prompt="Can you tell me about this project?",
allowed_tools=["Read", "Glob", "Grep"],
model="sonnet",
)
print(response.response)
print(f"Cost: ${response.cost:.4f}")
print(f"Output tokens: {response.output_tokens}") # billed output, reasoning included
print(f"Session: {response.session_id}")
# Resume the conversation using the session_id
follow_up = await shell.execute(
cwd="/path/to/project",
prompt="Now refactor the auth module based on your findings",
allowed_tools=["Read", "Edit", "Bash"],
model="sonnet",
session_id=response.session_id,
)
output_tokensis a cost measure: the billed output-token count, which includes reasoning tokens (they are billed at the output rate). It is reported consistently across all adapters.
See more examples for isolation and execution hosts, failure handling, streaming, model discovery, health checks, tool restrictions, MCP servers, packages, and logging.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_shell_py-0.4.0.tar.gz.
File metadata
- Download URL: agent_shell_py-0.4.0.tar.gz
- Upload date:
- Size: 745.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
211f0820849bd778df1e6337583089d6fc2871e699c5dd1b128bb68c52fff6c3
|
|
| MD5 |
d81d14fb80d6120ea93cb594a10f3df3
|
|
| BLAKE2b-256 |
7e2d162e36c35d65d2c76cad9c5f11fdbf35e072fa099c2d191e5a600fd1edc7
|
Provenance
The following attestation bundles were made for agent_shell_py-0.4.0.tar.gz:
Publisher:
publish.yml on ScottRBK/agent-shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_shell_py-0.4.0.tar.gz -
Subject digest:
211f0820849bd778df1e6337583089d6fc2871e699c5dd1b128bb68c52fff6c3 - Sigstore transparency entry: 2742906616
- Sigstore integration time:
-
Permalink:
ScottRBK/agent-shell@a23b692f8a15ba95cc391e92ad94bbdbc812c5f5 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/ScottRBK
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a23b692f8a15ba95cc391e92ad94bbdbc812c5f5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file agent_shell_py-0.4.0-py3-none-any.whl.
File metadata
- Download URL: agent_shell_py-0.4.0-py3-none-any.whl
- Upload date:
- Size: 108.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb06a6bba1a0bccc1bcaac07719837a74e09138569ad4938d9a5874bbb889dc3
|
|
| MD5 |
2d28782776cec5717c66c33b11acfd0a
|
|
| BLAKE2b-256 |
2845ec1e41e2f41eb840deef04dd5bbbddb72ebaabbe781378af986e53e66258
|
Provenance
The following attestation bundles were made for agent_shell_py-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on ScottRBK/agent-shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_shell_py-0.4.0-py3-none-any.whl -
Subject digest:
fb06a6bba1a0bccc1bcaac07719837a74e09138569ad4938d9a5874bbb889dc3 - Sigstore transparency entry: 2742906662
- Sigstore integration time:
-
Permalink:
ScottRBK/agent-shell@a23b692f8a15ba95cc391e92ad94bbdbc812c5f5 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/ScottRBK
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a23b692f8a15ba95cc391e92ad94bbdbc812c5f5 -
Trigger Event:
release
-
Statement type: