Skip to main content

open_agent/client/
state.rs

1/// A reusable conversation client with optional automatic tool execution.
2///
3/// Manual mode streams blocks as they arrive. Auto mode runs tool rounds first,
4/// then yields the final response. Use [`Client::interrupt_handle`] for cancellation
5/// from another task without locking the client across an await.
6pub struct Client {
7    options: AgentOptions,
8    history: Vec<Message>,
9    current_stream: Option<EventStream>,
10    http_client: reqwest::Client,
11    interrupted: Arc<AtomicBool>,
12    // None means this request has not run the auto loop; an exhausted iterator
13    // records completion without retaining or cloning delivered blocks.
14    auto_output: Option<std::vec::IntoIter<ContentBlock>>,
15    manual_receive_buffer: Vec<ContentBlock>,
16    last_finish_reason: Option<FinishReason>,
17    last_reasoning: String,
18}