Python SDK and hosted client for Agntz
Project description
Agntz Python
Python SDK and hosted client for Agntz.
The compatibility rule is simple: an agent definition YAML file should have the same observable behavior in the TypeScript and Python runtimes. Python code uses Python naming conventions, but the agent, run, session, trace, and tool concepts match the TypeScript SDK.
Install
pip install agntz
For local LLM execution through LiteLLM:
pip install "agntz[litellm]"
Create an agent
Save this as agents/support.yaml:
id: support
kind: llm
name: Support Assistant
description: Answers support questions with a concise plan.
model:
provider: openai
name: gpt-5.4
temperature: 0.2
instruction: |
You are a careful support agent.
prompt: |
Help with this request: {{userQuery}}
inputSchema:
userQuery: string
outputSchema:
answer: string
confidence: number
The same file can be loaded by the TypeScript and Python SDKs.
Run locally
from agntz import LiteLLMModelProvider, agntz
client = agntz(
agents="./agents",
model_provider=LiteLLMModelProvider(),
)
result = client.agents.run(
agent_id="support",
input={"userQuery": "Help me debug this invoice"},
)
print(result.output)
print(result.session_id)
Use client.agents.arun(...) inside an existing event loop.
Hosted client
import os
from agntz import AgntzClient
client = AgntzClient(
api_key=os.environ["AGNTZ_API_KEY"],
base_url="https://api.agntz.co",
)
result = client.agents.run(agent_id="support", input="Hello")
The async hosted client has the same resource shape:
from agntz import AsyncAgntzClient
async with AsyncAgntzClient(api_key="...", base_url="https://api.agntz.co") as client:
result = await client.agents.run(agent_id="support", input="Hello")
Pass runtime namespace grants with context when the run needs resource access:
result = client.agents.run(
agent_id="support",
input="Hello",
context=["app/user/u_123"],
)
Local tools
from typing import Any
from pydantic import BaseModel
from agntz import LiteLLMModelProvider, agntz, tool
class LookupInput(BaseModel):
order_id: str
def lookup_order(args: LookupInput) -> dict[str, Any]:
return {"status": "shipped", "eta": "Tomorrow"}
client = agntz(
agents="./agents",
tools=[
tool(
name="lookup_order",
description="Look up an order by ID",
input_schema=LookupInput,
execute=lookup_order,
)
],
model_provider=LiteLLMModelProvider(),
)
Reference the tool from YAML:
tools:
- kind: local
tools: [lookup_order]
LLM agents can also call HTTP tools, MCP tools over HTTP JSON-RPC, and agent-as-tool entries from the same manifest tool declarations used by the TypeScript runtime.
Sessions
Pass the same session_id across runs to continue a conversation. Local
sessions are persisted by the configured store and are replayed into model calls.
first = client.agents.run(
agent_id="support",
input={"userQuery": "Hi, I need help"},
session_id="customer-42",
)
second = client.agents.run(
agent_id="support",
input={"userQuery": "My order is #12345"},
session_id=first.session_id,
)
messages = client.sessions.get_messages("customer-42")
Runs and traces
Local execution records runs, sessions, and trace spans. The same store backs all three surfaces.
runs = client.runs.list(status="completed")
trace_rows = client.traces.list(agent_id="support")
trace_id = trace_rows["rows"][0]["traceId"]
detail = client.traces.get(trace_id)
print(detail["summary"])
print(detail["spans"])
SQLite persistence
from agntz import LiteLLMModelProvider, SQLiteStore, agntz
client = agntz(
agents="./agents",
store=SQLiteStore("./agntz.sqlite"),
model_provider=LiteLLMModelProvider(),
)
SQLite persists local runs, trace spans, sessions, and messages across process restarts.
Memrez
The Python package includes the same namespace-grant and memrez core primitives as the TypeScript package.
from agntz.memrez import create_memrez
memrez = create_memrez()
memrez.write(["app/user/u_123"], "Prefers metric units.", topics_hint=["prefs"])
entries = memrez.read(["app/user/u_123"], "prefs")
CLI
agntz validate ./agents
agntz run ./agents support --input '{"userQuery":"hello"}'
Current parity
Implemented in this package:
- Hosted sync and async clients for run, run stream, runs, and traces.
- Local YAML execution for
llm,tool,sequential, andparallelagents. - Local Python tools, HTTP tools, MCP JSON-RPC tools, and agent-as-tool calls.
- Runtime namespace grants and the in-memory memrez core.
- LiteLLM-backed model execution with tool-call loop support.
- Memory and SQLite stores for runs, trace spans, sessions, and messages.
- Contract fixtures shared with the TypeScript manifest package.
Still intentionally outside this first Python package slice:
- The hosted app and worker remain TypeScript services.
- Python does not reimplement the TypeScript eval product yet.
- Streaming token deltas for local Python execution are not exposed yet.
Development
python -m venv .venv
.venv/bin/python -m pip install -e '.[dev,litellm]'
.venv/bin/python -m pytest
.venv/bin/python -m ruff check .
.venv/bin/python -m basedpyright
.venv/bin/python -m build
Project details
Release history Release notifications | RSS feed
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 agntz-0.1.0.tar.gz.
File metadata
- Download URL: agntz-0.1.0.tar.gz
- Upload date:
- Size: 50.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ad0b22c9bf3b25aa4f2421c243d88d5eef4020ce9ba6b295ba256a56c724ef4
|
|
| MD5 |
c05367fc70a3613a5d44b290ba311096
|
|
| BLAKE2b-256 |
edcd97bb6c0d3a26dd5f9c7199d378018c038ccfc005e15a35c851fb60988eb1
|
Provenance
The following attestation bundles were made for agntz-0.1.0.tar.gz:
Publisher:
python-release.yml on aparry3/agntz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agntz-0.1.0.tar.gz -
Subject digest:
8ad0b22c9bf3b25aa4f2421c243d88d5eef4020ce9ba6b295ba256a56c724ef4 - Sigstore transparency entry: 1673515220
- Sigstore integration time:
-
Permalink:
aparry3/agntz@c24f408546caf40586ea86d782585ff29207bf57 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/aparry3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@c24f408546caf40586ea86d782585ff29207bf57 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file agntz-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agntz-0.1.0-py3-none-any.whl
- Upload date:
- Size: 55.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3f4777b87551e63c75fc669e7611cbcc823f6c0a1b54e7309cde9b748907804
|
|
| MD5 |
1821b4ed108cafdf7c5b33f5d8780709
|
|
| BLAKE2b-256 |
026945ca077c28fe77bf3bfca7172f744499fb45f80e86ccf576bae13d97cc90
|
Provenance
The following attestation bundles were made for agntz-0.1.0-py3-none-any.whl:
Publisher:
python-release.yml on aparry3/agntz
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agntz-0.1.0-py3-none-any.whl -
Subject digest:
a3f4777b87551e63c75fc669e7611cbcc823f6c0a1b54e7309cde9b748907804 - Sigstore transparency entry: 1673515239
- Sigstore integration time:
-
Permalink:
aparry3/agntz@c24f408546caf40586ea86d782585ff29207bf57 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/aparry3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@c24f408546caf40586ea86d782585ff29207bf57 -
Trigger Event:
workflow_dispatch
-
Statement type: