pub struct ChatHistory {
lines: Vec<(String, HistoryEntryType)>,
open_tool_calls: HashMap<String, ToolCallParams>,
}Expand description
Chat history data
Fields§
§lines: Vec<(String, HistoryEntryType)>Full chat history (split into lines, but not broken by terminal width)
open_tool_calls: HashMap<String, ToolCallParams>Not-yet-resolved tool calls (for Self::push_raw())
Implementations§
Source§impl ChatHistory
impl ChatHistory
Sourcepub fn push_raw(&mut self, agent: &Agent, msg: &ChatMessage)
pub fn push_raw(&mut self, agent: &Agent, msg: &ChatMessage)
Push and format a raw ChatMessage into the history.
Sourcepub fn lines(&self) -> &[(String, HistoryEntryType)]
pub fn lines(&self) -> &[(String, HistoryEntryType)]
Return the chat history.
Sourcepub fn push(
&mut self,
string: &str,
kind: HistoryEntryType,
force_new_line: bool,
)
pub fn push( &mut self, string: &str, kind: HistoryEntryType, force_new_line: bool, )
Append the given string of type ct to the history.
If force_new_line is false and the last line is of the same type, append to it; if it is
true, always create a new line.
Sourcepub fn push_lines(
&mut self,
string: &str,
kind: HistoryEntryType,
force_new_line: bool,
)
pub fn push_lines( &mut self, string: &str, kind: HistoryEntryType, force_new_line: bool, )
Append the given multi-line string to the history.
Splits string at newlines and appends each line as its own entry, so that entries in
Self::lines() never span multiple physical lines.
If force_new_line is false and the last line is of the same type, append to it; if it is
true, always create a new line.
Sourcepub fn force_resolve_unresolved_tool_calls(&mut self, agent: &mut Agent)
pub fn force_resolve_unresolved_tool_calls(&mut self, agent: &mut Agent)
Force-resolve all open tool calls.
Push an error for each tool call that is in the history that has not yet received a result. This is useful after loading history from an existing session state, which may be incomplete.