Skip to main content

AGNT5 Python SDK

CI License

Build reliable AI agents and durable workflows in Python. The AGNT5 SDK provides typed components, workflow checkpoints, retries, streaming, tools, human-in-the-loop coordination, evaluation, and runtime observability.

Requirements

  • Python 3.11 or newer
  • An AGNT5 runtime for deployed execution

Installation

pip install agnt5

Quick start

Define a function. Type hints are used to derive its input and output schema.

from agnt5 import FunctionContext, function


@function(retries=3, backoff="exponential")
async def greet(ctx: FunctionContext, name: str) -> dict[str, str]:
    ctx.logger.info("greeting user", extra={"name": name})
    return {"message": f"Hello, {name}!"}

Register application components with a worker for runtime-backed execution:

import asyncio

from agnt5 import Worker


async def main() -> None:
    worker = Worker(service_name="hello-python")
    await worker.run()


asyncio.run(main())

Decorated functions, workflows, agents, tools, and scorers are registered when their modules are imported. See examples/app.py for a complete application entrypoint.

Invoke a deployed component

from agnt5 import Client

client = Client(
    gateway_url="https://gw.agnt5.com",
    api_key="agnt5_sk_...",
    deployment_id="deployment-id",
)

result = client.run("greet", {"name": "Ada"})
print(result)

Client also supports asynchronous submission, status and result polling, streaming events, batches, cancellation, workflow resume, chat, and evaluation. Configuration can be supplied explicitly or through AGNT5_GATEWAY_URL, AGNT5_API_KEY, and AGNT5_DEPLOYMENT_ID.

Core APIs

API Purpose
@function Typed, retryable units of work
@workflow Durable multi-step orchestration and checkpointing
Agent and @agent Model and tool orchestration
@tool Typed tools with generated schemas
ctx.state Durable workflow and component state
ctx.memory Conversation and application memory
Client / AsyncClient Invoke and observe deployed components
Worker Register components and serve runtime dispatch

In async workflows, use await ctx.state.set_async(key, value) and await ctx.state.delete_async(key). These await the runtime's durable acknowledgment while allowing other workflows to run. Reads remain local via ctx.state.get(key). The existing synchronous set and delete methods remain supported, but block their calling thread while waiting for persistence.

The shared Rust runtime foundation lives in agnt5dev/sdk-core. Vendor sandbox adapters live in agnt5dev/sdk-integrations.

Examples and documentation

  • examples/ contains functions, workflows, agents, tools, streaming, HITL, MCP, chat, and evaluation examples.
  • docs/ contains SDK-specific guides.
  • AGNT5 documentation covers platform concepts and deployment.

Development

uv sync --all-groups
uv run ruff check src tests
uv run pytest tests/unit -q
uv build --sdist

Development builds use a sibling checkout of sdk-core.

Contributing

See CONTRIBUTING.md. Report security issues according to SECURITY.md.

License

Licensed under the Apache License 2.0.

Response wait

Run and stream calls wait up to 5 minutes by default. Set the per-call wait to any value from zero to 24 hours. Zero returns a pending receipt immediately after acceptance. This controls response waiting, not the workflow execution deadline: accepted work continues when the wait expires or the client disconnects.

result = client.run("process_order", order, component_type="workflow", wait_timeout=60)
for event in client.stream_events("process_order", order, component_type="workflow", wait_timeout=60):
    print(event.event_type, event.run_id)

wait_timeout uses seconds and also applies to async run and stream_events. Run calls return 202 pending receipts directly, without additional polling. Event streams emit stream.wait_expired when the wait expires, or stream.detached for a 202 receipt. Use the run ID to read status/results. Chunk-only stream raises RunError with the run ID when waiting ends.

The default HTTP timeout allows at least the wait plus 10 seconds, or the client timeout if longer. Pass timeout=75 to set it explicitly. Python's HTTP timeout limits individual network operations; wait_timeout bounds the gateway wait.

Structured assertions

structured_assertions is a reserved built-in scorer, so workers need no user registration. The local helper uses the same SDK-core implementation as the runtime:

from agnt5.eval import ScorerInput, structured_assertions

result = structured_assertions(
    ScorerInput(output=[1, 2, 3], expected={"expected_length": 3}),
    {"assertions": [
        {"name": "unique_ids", "expr": "unique(output_json)"},
        {"name": "count", "expr": "size(output_json) == expected.expected_length"},
    ]},
)

The score is the fraction of assertions that pass; score_threshold defaults to

  1. Configuration and input errors always fail. See the SDK-core contract for supported expressions and execution limits. Requires the matching native extension.

Metadata

Release files for agnt5 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agnt5 0.14.0
File Size Uploaded
agnt5-0.14.0.tar.gz 920.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for agnt5 0.14.0
File Interpreter ABI Platform
agnt5-0.14.0-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details
agnt5-0.14.0-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details
agnt5-0.14.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details

Total release size: 55.4 MB

Release files / agnt5-0.14.0.tar.gz

Download URL agnt5-0.14.0.tar.gz
Size 920.7 kB
Tags Source
SHA-256 checksum
How to use checksums
607f8221971652ac8ca76cbd32aeb60c74ca544487ed9c10cbcd24419c52e90e
BLAKE2b-256 checksum
How to use checksums
04d2463d6b20e033734bc5d1f7445517ea0fbb831beebb8ea73aa52b86e8e0e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / agnt5-0.14.0-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL agnt5-0.14.0-cp310-abi3-manylinux_2_28_x86_64.whl
Size 18.4 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
123c494fbbf945fffb641dfdfc60edfbb4e3f97f3374e1196b7759c3c1a9bd3c
BLAKE2b-256 checksum
How to use checksums
34123f31098bdfeb175932000cd493694f4df12d71d9fd25054c4e5ca314d2d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / agnt5-0.14.0-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL agnt5-0.14.0-cp310-abi3-manylinux_2_28_aarch64.whl
Size 19.4 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
6cef4f8c3216938656e8ff50f7566dbc8a71fba3bcd98c606b57ff947bb41fad
BLAKE2b-256 checksum
How to use checksums
266b92954d77ab887a9bab246b1f34f91aeb8cf7da272944b9b21a671aeb75cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / agnt5-0.14.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL agnt5-0.14.0-cp310-abi3-macosx_11_0_arm64.whl
Size 16.6 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
94237655f32c4d92bb13c7e97b9d8cb2d70cbb9aa19e21976126940dd072e793
BLAKE2b-256 checksum
How to use checksums
af326af1b95b26d05a32190ef3606ec0483d16b920b1243419136ead38e0e4b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.14.0 This release

4 release files

0.13.6

4 release files

0.13.5

4 release files

0.13.4

4 release files

0.13.3

4 release files

0.13.2

4 release files

0.13.1

4 release files

0.13.0

4 release files

0.12.0

4 release files

0.9.8

3 release files

0.9.7

3 release files

0.9.6

3 release files

0.9.5

3 release files

0.9.4

3 release files

0.9.3

3 release files

0.9.2

3 release files

0.9.1

3 release files

0.9.0

4 release files

0.8.7

4 release files

0.8.5

4 release files

0.8.4

4 release files

0.8.3

4 release files

0.8.2

4 release files

0.8.1

4 release files

0.8.0

4 release files

0.7.20

4 release files

0.7.18

4 release files

0.7.11

4 release files

0.7.10

4 release files

0.7.9

4 release files

0.7.8

4 release files

0.7.6

4 release files

0.7.5

4 release files

0.7.4

4 release files

0.7.3

4 release files

0.7.2

4 release files

0.7.1

4 release files

0.6.1

4 release files

0.6.0

4 release files

0.5.2

4 release files

0.5.1

4 release files

0.5.0

4 release files

0.4.3

4 release files

0.4.2

4 release files

0.4.1

4 release files

0.4.0

4 release files

0.3.7

4 release files

0.3.6

4 release files

0.3.5

4 release files

0.3.4

4 release files

0.3.3

4 release files

0.3.1

4 release files

0.2.7

4 release files

0.2.6

4 release files

0.2.5

4 release files

0.2.4

4 release files

0.2.3

4 release files

0.2.2

3 release files

0.2.1

3 release files

0.2.0

5 release files

0.1.3

6 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page