Skip to main content

Runlayer Hooks SDK for Python agent runtimes

Project description

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_event
  • before_tool
  • after_tool
  • run_tool
  • should_enforce_tool

The package also exports send_runlayer_preflight.

Framework tool adapters

Dependency-free adapters wrap common tool dictionary shapes:

  • with_runlayer_vercel_ai_tool
  • with_runlayer_vercel_ai_tools
  • with_runlayer_openai_agents_tool
  • with_runlayer_google_adk_tool
  • run_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_hooks
  • emit_claude_agent_sdk_transcript_stop
  • claude_agent_sdk_assistant_message_to_transcript_line
  • tool_type_from_name

TypeScript-style camelCase aliases are also available for SDK parity.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

runlayer_hooks_sdk-0.1.0.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

runlayer_hooks_sdk-0.1.0-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file runlayer_hooks_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: runlayer_hooks_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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

Hashes for runlayer_hooks_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15b7020998fed2fedfac81288d87310d7a630715da00c355a2fef8452b4246d7
MD5 a3d99687d56589a6cae41bd68a71aa2c
BLAKE2b-256 4e4ba142a1fb63f6472aff20145e3b0e66ad5c86fe2bb66edb40bed512638bee

See more details on using hashes here.

File details

Details for the file runlayer_hooks_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: runlayer_hooks_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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

Hashes for runlayer_hooks_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8275d0f6ca1337bfcd244e498351091acdb9c9e23a3c2d0ef25fe9c684bc1dc
MD5 956fc3bc0ee14e49de35447f3b86528f
BLAKE2b-256 a7650b8afbcee5f5486718ad40c1723180804dfec6d48d730384997203539d97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page