Metadata-Version: 2.5
Name: agentspec-sdk
Version: 0.7.3
Summary: Universal Agent Manifest SDK for Python agents
Requires-Python: >=3.10
Requires-Dist: httpx>=0.28.1
Requires-Dist: pydantic>=2.14.1
Requires-Dist: pyyaml>=6.0.3
Provides-Extra: dev
Requires-Dist: langchain-core>=1.0.0; extra == 'dev'
Requires-Dist: langgraph-checkpoint>=4.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=1.4.1; extra == 'dev'
Requires-Dist: pytest>=9.1.1; extra == 'dev'
Requires-Dist: respx>=0.23.1; extra == 'dev'
Description-Content-Type: text/markdown

# agentspec-sdk

Python runtime SDK for [AgentSpec](https://github.com/agents-oss/agentspec): serves `GET /agentspec/health` and pushes state to the control plane from an agent described by `agent.yaml`.

```bash
pip install agentspec-sdk
```

```python
from agentspec_sdk import AgentSpecReporter

reporter = AgentSpecReporter.from_yaml("agent.yaml")

# WSGI app answering GET /agentspec/health with the TypeScript HealthReport keys
# (agentName, checks[].latencyMs), so the sidecar sees the SDK. Mount it in your framework.
app = reporter.wsgi_app()
```

Mount the app so the full request path is `/agentspec/health`. At the root it answers that path directly. Under a
prefix, the dispatcher moves the prefix into `SCRIPT_NAME`; the app compares `SCRIPT_NAME + PATH_INFO`, so
mounting it at `/agentspec` (for example `DispatcherMiddleware(fallback, {"/agentspec": reporter.wsgi_app()})`)
serves `/agentspec/health` too.

## Evidence points

The SDK is the Python runtime SDK of ADR-0038: framework-agnostic, the same evidence points and record shapes as `@agentspec/sdk/runtime` in TypeScript. Create the reporter first, then wrap the operations the rules are about:

```python
import agentspec_sdk
from agentspec_sdk import AgentSpecReporter

reporter = AgentSpecReporter.from_yaml("agent.yaml")


@agentspec_sdk.guardrail("input")      # SEC-LLM-01; "output" for SEC-LLM-02
def run_input_guardrails(text: str) -> str:
    return text


@agentspec_sdk.tool("search-web")      # TOOL-01
def search_web(query: str) -> list[str]:
    return []


reporter.start_push_mode()  # heartbeat to the sidecar on loopback, with each evidence point's state and records
```

| Helper | Contract name | Wraps |
|---|---|---|
| `guardrail("input" \| "output")` | `guardrail` | A guardrail function (decorator) or block (`with`) |
| `tool(name)` | `tool` | A local tool function |
| `mcp_client(session, server)` | `mcpClient` | A stdio MCP client session |
| `memory_write(backend)` | `memoryWrite` | A LangGraph checkpointer or Store: scrubs, applies the TTL, audits |
| `vector_store(client, namespace=None)` | `vectorStore` | A vector store client |
| `structured_logging(logger=None)` | `logging` | The logger's stream handlers: JSON lines |

Each applicable evidence point is reported `fired`, `wired` or `not_wired`; `not_wired` never passes. See the [runtime SDK concept page](../../docs/concepts/runtime-sdk.md) and the [evidence wiring guide](../../docs/guides/wire-evidence-points.md).

The distribution is `agentspec-sdk` and the import is `agentspec_sdk`. The PyPI name `agentspec` belongs to an unrelated project.
