Runlayer Hooks Python SDK
Python SDK companion to @runlayer/hooks-sdk.
Configure
export RUNLAYER_BASE_URL="https://your-runlayer-instance.com"
export RUNLAYER_API_KEY="rl_..."
Agent account auth is also supported:
export RUNLAYER_BASE_URL="https://your-runlayer-instance.com"
export RUNLAYER_AGENT_CLIENT_ID="client_..."
export RUNLAYER_AGENT_CLIENT_SECRET="..."
Optional OBO subject fields:
export RUNLAYER_AGENT_SUBJECT_TOKEN="user@example.com"
export RUNLAYER_AGENT_SUBJECT_TOKEN_TYPE="urn:runlayer:token-type:user-email"
Optional runtime controls:
| Variable | Purpose |
|---|---|
RUNLAYER_HOOK_TIMEOUT_MS |
Hook request timeout. Defaults to 10000. |
RUNLAYER_HOOK_MAX_TOOL_OUTPUT_BYTES |
Maximum serialized tool output sent to Runlayer. Defaults to 65536. |
RUNLAYER_HOOK_ENFORCEMENT_FAILURE_MODE |
Defaults to closed; set to open only if tool calls should continue when Runlayer is unreachable. |
RUNLAYER_ALLOW_INSECURE_TRANSPORT=1 |
Allow non-HTTPS RUNLAYER_BASE_URL for local development. |
Usage
from runlayer_sdk import RunlayerClient
runlayer = RunlayerClient.from_env(client_version="my-agent/1.0.0")
def run_local_tool(tool_input: dict[str, object]) -> str:
return "tool output"
output = runlayer.run_tool(
execute=run_local_tool,
session_id="session-id",
tool_input={"command": "cat README.md"},
tool_name="Bash",
tool_type="shell",
)
Use tool_enforcement to skip Runlayer-owned MCP tools or proxy URLs:
runlayer = RunlayerClient.from_env(
tool_enforcement={
"ignored_mcp_server_names": ["github-preview"],
"skip_runlayer_mcp_proxy_urls": True,
}
)
RunlayerClient exposes:
emit_eventbefore_toolafter_toolrun_toolshould_enforce_tool
The package also exports send_runlayer_preflight.
Troubleshooting: sessions not appearing
Lifecycle hooks send events best-effort and do not raise on their own. If the
server accepts an event but does not record it, it responds with
status: "ignored" and a reason. The client logs a one-time warning to stderr
for the actionable reasons so a misconfiguration is not silent:
client_not_enabled— the SDK session-monitoring client is off for this workspace. Enable the client (and any required SDK toggle) in Runlayer settings. This is a separate switch from tool enforcement, so both must be on to get full session + tool telemetry.actor_unresolved— the request authenticated but Runlayer could not map it to a user/agent. Organization-level API keys are not supported for session attribution. Use a personal API key (RUNLAYER_API_KEY) or agent-account credentials (RUNLAYER_AGENT_CLIENT_ID/RUNLAYER_AGENT_CLIENT_SECRET).
Set RUNLAYER_HOOK_DEBUG=1 to also log transient ignore reasons and network
failures. Run send_runlayer_preflight() for an explicit check.
Framework tool adapters
Dependency-free adapters wrap common tool dictionary shapes:
with_runlayer_vercel_ai_toolwith_runlayer_vercel_ai_toolswith_runlayer_openai_agents_toolwith_runlayer_google_adk_toolrun_runlayer_adapter_tool
Claude Agent SDK hooks
Use the adapter helpers when a Python agent runtime wants the same Claude Agent SDK hook output shapes as the Hooks TypeScript SDK:
from runlayer_sdk import RunlayerClient, create_claude_agent_sdk_hooks
runlayer = RunlayerClient.from_env()
hooks = create_claude_agent_sdk_hooks(runlayer, include_stop=False)
The adapter exports:
create_claude_agent_sdk_hooksemit_claude_agent_sdk_transcript_stopclaude_agent_sdk_assistant_message_to_transcript_linetool_type_from_name
TypeScript-style camelCase aliases are also available for SDK parity.
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 runlayer_hooks_sdk-0.1.1.tar.gz.
File metadata
- Download URL: runlayer_hooks_sdk-0.1.1.tar.gz
- Upload date:
- Size: 41.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79bce3f688bf6a9519c469741f84b3db1e361f6c3b4613c3d5d577133508019d
|
|
| MD5 |
3e9fa8245c9353f02c0dfe5dc6864709
|
|
| BLAKE2b-256 |
63efa1ab7d6028c99ca5ef3a55e04a194305d78608add4126eebb9ff37589952
|
File details
Details for the file runlayer_hooks_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: runlayer_hooks_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 25.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
210f7c00801293387bc6826d2dd462b8f56d1f19c41b7a9f44247cd97cb916d8
|
|
| MD5 |
3061d11638cff719741111db536bff29
|
|
| BLAKE2b-256 |
d2418d3f713d509883afa3ed32dfef43a2fc2e327019d492ff14e4d819d8f520
|