Skip to main content

Module agent

Module agent 

Source
Expand description

The low-level API: start a run, get its events.

RemoteAgent adds almost nothing to Transport — a request builder, and a stream that flattens connecting into streaming. It delivers checked typed events; a proxy or recorder needing the original JSON calls Transport::run and takes TransportStream::into_json.

For a UI, Thread sits on top of this and does the assembling.

use ag_ui::client::{HttpAgent, RunParams};
use futures_util::StreamExt;

let agent = HttpAgent::builder("https://example.com/agent")
    .header("authorization", "Bearer …")
    .build()?;

let mut events = agent.run_events(
    RunParams::new("thread-1", "run-1").user("msg-1", "What is the weather?"),
);

while let Some(event) = events.next().await {
    println!("{:?}", event?.event_type());
}

Structs§

HttpAgent
An HTTP endpoint and reusable connection settings. Create independent local conversations with HttpAgent::thread, or consume typed events with run_events.
HttpAgentBuilder
Builds an HttpAgent: base URL, headers, timeouts.
RemoteAgent
A checked typed event interface over any Transport. HTTP, an in-process agent or a recorded fixture can supply events without state management.
RunParams
What to send when starting a run.