Client
AgentClient submits, streams, and cancels turns through an agent server’s
HTTP routes.
from pyrula.agents.client.client import AgentClient
client = AgentClient("https://agents.example.com")
handle = await client.submit("support", message="where is my order?")async for event in client.stream("support", handle.turn_id): print(event.kind, event.payload)submit returns a handle with the turn id and stream path. stream yields events
until the turn finishes.
One-shot
Section titled “One-shot”run submits a turn and drains its stream, returning the full event list when the turn
ends:
events = await client.run("support", message="where is my order?")Reconnecting
Section titled “Reconnecting”stream takes a last_event_id. Pass the id of the last event you saw and the server
resumes from there, so a dropped connection doesn’t lose events or replay ones you
already handled.
async for event in client.stream("support", turn_id, last_event_id=seen): ...Status and cancel
Section titled “Status and cancel”info = await client.status("support", turn_id)await client.cancel("support", turn_id)idempotency_key on submit and run makes a retried submission safe: the same key
returns the existing turn instead of starting a new one.