orchagent SDK
Official Python SDK for building orchagent agents with agent-to-agent call support.
Installation
pip install orchagent-sdk
Note: The pip package is
orchagent-sdkbut the Python import isfrom orchagent import .... This is a common Python convention (e.g.Pillow→import PIL).
Quick Start
# pip install orchagent-sdk (package name)
from orchagent import AgentClient # module name
# Create a client (uses ORCHAGENT_SERVICE_KEY env var)
client = AgentClient()
# Call another agent
async def my_orchestrator(input_data):
result = await client.call("joe/leak-finder@v1", {"url": input_data["repo"]})
return result
Features
- Agent-to-agent calls - Call other agents from within your orchestrator agent
- Service key authentication - Automatic auth via
ORCHAGENT_SERVICE_KEYenv var - Call chain tracking - Prevents circular dependencies (A calls B calls A)
- Deadline propagation - Timeout context flows through the call chain
- Local execution mode - Test orchestrators locally with
orch run --with-deps
Usage
Basic Usage
from orchagent import AgentClient
client = AgentClient()
result = await client.call("org/agent@v1", {"input": "data"})
# result is the raw agent output — the gateway envelope is auto-unwrapped
With FastAPI
Extract call context from incoming requests:
from fastapi import Request
from orchagent import AgentClient
@app.post("/analyze")
async def analyze(request: Request, input: AnalyzeInput):
# Automatically extracts call chain, deadline, etc. from request headers
client = AgentClient.from_request(request)
secrets = await client.call("joe/leak-finder@v1", {"url": input.repo_url})
return {"secrets": secrets}
Error Handling
from orchagent import (
AgentClient,
DependencyCallError,
CallChainCycleError,
TimeoutExceededError,
)
try:
result = await client.call("org/agent@v1", data)
except CallChainCycleError:
# Would create a circular dependency
pass
except TimeoutExceededError:
# Deadline passed
pass
except DependencyCallError as e:
# Agent returned an error
print(f"Status: {e.status_code}, Body: {e.response_body}")
Local Execution Mode
When running with orch run --with-deps, the SDK automatically detects local mode and spawns sub-agents as local subprocesses instead of making HTTP calls.
# Agents are executed locally as subprocesses
orch run orchagent/security-review --with-deps --input '{"path": "."}'
This is controlled by the ORCHAGENT_LOCAL_EXECUTION=true environment variable, which the CLI sets automatically.
Environment Variables
| Variable | Description |
|---|---|
ORCHAGENT_SERVICE_KEY |
Service key for API authentication. Auto-injected by the gateway for agents with manifest dependencies — do not add to required_secrets |
ORCHAGENT_GATEWAY_URL |
Gateway URL (default: https://api.orchagent.io) |
ORCHAGENT_LOCAL_EXECUTION |
Enable local subprocess execution |
ORCHAGENT_AGENTS_DIR |
Path to local agents (default: ~/.orchagent/agents) |
API Reference
AgentClient
class AgentClient:
def __init__(
self,
service_key: str | None = None, # From ORCHAGENT_SERVICE_KEY
gateway_url: str | None = None, # From ORCHAGENT_GATEWAY_URL
call_chain: list[str] | None = None, # Current call chain
deadline_ms: int | None = None, # Deadline timestamp
max_hops: int | None = None, # Max remaining hops
): ...
@classmethod
def from_request(cls, request, service_key=None) -> "AgentClient": ...
async def call(
self,
agent_ref: str, # "org/agent@version"
input_data: dict, # Input payload
endpoint: str | None, # Optional endpoint override
timeout: float | None, # Optional timeout in seconds
) -> Any: ...
# Returns the raw agent output, not the gateway envelope.
# The gateway wraps responses in {"data": ..., "metadata": ...} —
# the SDK auto-unwraps this so you get the agent's output directly.
Exceptions
AgentClientError- Base exceptionDependencyCallError- Agent call failed (hasstatus_code,response_body)CallChainCycleError- Would create circular dependencyTimeoutExceededError- Deadline passedLocalExecutionError- Subprocess execution failed (hasexit_code,stderr)
License
MIT
Metadata
Release files for orchagent-sdk 0.1.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| orchagent_sdk-0.1.13.tar.gz | 21.6 kB | Without provenance | Details for orchagent_sdk-0.1.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| orchagent_sdk-0.1.13-py3-none-any.whl | Python 3 | none | any | Details for orchagent_sdk-0.1.13-py3-none-any.whl |
Total release size: 38.6 kB
Release files / orchagent_sdk-0.1.13.tar.gz
| Download URL | orchagent_sdk-0.1.13.tar.gz |
|---|---|
| Size | 21.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfc5d6804f5433f407acc0b12a0cfc195b31b3640c630a160ee51b9b05c16225
|
|
BLAKE2b-256 checksum How to use checksums |
90922683f0bba4aa7ed50a3f83176e6b04176bf6ec17ffd671403f9a0111e97d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.6
|
Release files / orchagent_sdk-0.1.13-py3-none-any.whl
| Download URL | orchagent_sdk-0.1.13-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d37fd089cd63d78ae2606907d625c74e44f71c68df7e98accb797d57729beff1
|
|
BLAKE2b-256 checksum How to use checksums |
7632543fc9979e202a48683423d8b3e2804a5e87e55bd4917dc55921de29a0e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.6
|
Security for orchagent-sdk 0.1.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.