open-agent-sdk 0.11.7

Production-ready Rust SDK for building AI agents over two wire protocols: OpenAI chat completions (LMStudio, Ollama, llama.cpp, vLLM, OpenRouter) and Anthropic messages. Features streaming, tools, hooks, retry logic, and comprehensive examples.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// A reusable conversation client with optional automatic tool execution.
///
/// Manual mode streams blocks as they arrive. Auto mode runs tool rounds first,
/// then yields the final response. Use [`Client::interrupt_handle`] for cancellation
/// from another task without locking the client across an await.
pub struct Client {
    options: AgentOptions,
    history: Vec<Message>,
    current_stream: Option<EventStream>,
    http_client: reqwest::Client,
    interrupted: Arc<AtomicBool>,
    // None means this request has not run the auto loop; an exhausted iterator
    // records completion without retaining or cloning delivered blocks.
    auto_output: Option<std::vec::IntoIter<ContentBlock>>,
    manual_receive_buffer: Vec<ContentBlock>,
    last_finish_reason: Option<FinishReason>,
    last_reasoning: String,
}