Skip to main content

say

Function say 

Source
pub async fn say(
    chat: &mut Chat,
    store: &Chats,
    cfg: &Config,
    text: &str,
) -> Result<()>
Expand description

One operator turn and one agent turn, appended.

The operator’s message is recorded and flushed to disk before the agent is invoked. That ordering is the whole contract of this function: a turn can fail, time out or hit a quota window, and the thing that must never be lost is the sentence the human typed on a phone that has since gone to sleep.

Returns Err when the agent turn did not produce an answer - but the transcript is already on disk and already explains itself, because the failure is appended as a MAGI_NOTE turn first. A caller handling the error should re-read the chat and show it, not discard it.