Octoroom.Agent.ConversationEvents (octoroom_agents v0.1.0)

Copy Markdown View Source

Accumulates observed text and emits finalized conversation items to the owner.

An assistant reply that's spoken is emitted twice with the same message_id: :playing when its text is done and its audio is playing, then :completed once it played to the end, or :interrupted with only the words that were heard. Without TTS, :completed means the text is done. Interrupted/failed items contain only text observed before that boundary. This event ledger is separate from the model's history and does not persist it.

Summary

Functions

Emits a reserved item. Its sequence may be lower than items already emitted.

Reserves the next sequence number for an item whose text arrives later, such as a user turn heard as audio and transcribed in the background. Returns {state, reservation}; pass the reservation to commit_reserved/4.

Emits a reserved item, or a new version of one already emitted (same message_id and sequence), even with empty text: an assistant reply shown as :playing and then cut off before any of it was heard.

Functions

append(state, role, text)

commit(state, role, status \\ :completed, extra \\ %{})

commit_reserved(state, role, reservation, text, extra \\ %{}, status \\ :completed)

Emits a reserved item. Its sequence may be lower than items already emitted.

new()

replace(state, role, text)

reserve(state)

Reserves the next sequence number for an item whose text arrives later, such as a user turn heard as audio and transcribed in the background. Returns {state, reservation}; pass the reservation to commit_reserved/4.

update_reserved(state, role, reservation, text, status)

Emits a reserved item, or a new version of one already emitted (same message_id and sequence), even with empty text: an assistant reply shown as :playing and then cut off before any of it was heard.