Quick Start

Initialize the SDK

Create an ALM instance with your agent configuration:

from r3fresh import ALM

alm = ALM(
    agent_id="my-agent",
    env="development",
    mode="stdout",  # or "http" with endpoint (base URL)
    agent_version="1.0.0",
)

Define Tools

Wrap your tool functions with automatic policy enforcement and instrumentation:

@alm.tool("search_web")
def search_web(query: str) -> str:
    """Search the web for information."""
    # Your tool implementation
    return f"Results for: {query}"

@alm.tool("summarize")  # Optional: specify tool name
def summarize(text: str) -> str:
    """Summarize text."""
    return "summary"

Run Your Agent

Use a run context manager to track execution. All events within the run are correlated via run_id:

with alm.run(purpose="Process user query"):
    result = search_web("Python SDK documentation")
    summary = summarize(result)
    print(summary)

# run.end event automatically emitted with summary statistics

Development Output

With mode="stdout", events are printed as JSON lines:

{"event_type": "run.start", ...}
{"event_type": "tool.request", ...}
{"event_type": "policy.decision", ...}
{"event_type": "tool.response", ...}
{"event_type": "run.end", ...}