Use the official orchagent-sdk package for calling other agents
The orchagent SDK provides a simple interface for building orchestrator agents that call other agents. It handles authentication, call chain propagation, and error handling automatically. SDKs are available for both Python and JavaScript/TypeScript.
The SDK provides AgentClient for calling other agents from within your agent. Most agents use stdin/stdout — create a client with no arguments and the SDK reads all context from environment variables:
Both SDKs automatically detect whether to route calls locally or through the gateway based on the ORCHAGENT_LOCAL_EXECUTION environment variable.
Mode
ORCHAGENT_LOCAL_EXECUTION
Behavior
Server
Not set or false
Calls route through api.orchagent.io
Local
true
Calls route to locally running agents
When you run an orchestrator with orch run --with-deps, the CLI automatically sets ORCHAGENT_LOCAL_EXECUTION=true so your agent calls dependencies locally.
In local mode, calls go directly to locally running agent processes. The SDK spawns subprocesses using python3 for .py entrypoints and node for .js entrypoints.
Both SDKs provide specific exception/error types for different failure modes:
Python
JavaScript
Copy
from orchagent import ( AgentClient, DependencyCallError, TimeoutExceededError, CallChainCycleError)try: result = await client.call("joe/analyzer@v1", input_data)except DependencyCallError as e: # The called agent returned an error print(f"Agent error: {e.status_code}") print(f"Response: {e.response_body}")except TimeoutExceededError: # Request exceeded deadline print("Call timed out")except CallChainCycleError: # Cycle detected (A -> B -> A) print("Circular dependency detected")
Use AgentClient() / new AgentClient() for stdin/stdout agents (the common case) — the SDK reads all context from environment variables injected by the gateway. Use from_request() / fromRequest() only for custom HTTP servers (FastAPI, Express, etc.) where you need to propagate call chain and deadline from incoming request headers.
Handle all exception types - Don’t let DependencyCallError crash your agent
Use parallel calls when possible - Fan-out to independent agents with asyncio.gather() (Python) or Promise.allSettled() (JavaScript)
Pin dependency versions - Use org/agent@v1, not org/agent@latest
Set reasonable timeouts - Account for all dependency calls in your timeout_ms
Return partial results on failure - Don’t fail completely if one dependency fails
Python
JavaScript
Copy
# Parallel calls with error handlingasync def review(client, repo): secrets, vulns = await asyncio.gather( client.call("joe/leak-finder@v1", {"url": repo}), client.call("joe/vuln-scanner@v1", {"url": repo}), return_exceptions=True ) return { "secrets": secrets if not isinstance(secrets, Exception) else None, "vulnerabilities": vulns if not isinstance(vulns, Exception) else None, }
Send messages from your agents to orch-hq. Use messages for briefings, alerts, reports — anything your agent wants to tell you. See the dedicated Agent Messages page for the full reference.
Copy
from orchagent import messagemessage.send("Daily Brief", "Here's what's happening today...")message.send("Build Failed", "Error in main.py line 42", level="error")
Create and manage tasks from your agents. Tasks appear in orch-hq’s Tasks panel, grouped by urgency. See the dedicated Agent Tasks page for the full reference.