Expand description
The turn driver: keeps asking Azure while a round answers itself with tool calls, and ends on an answer, an error, a suspension, or the round budget.
ModulesΒ§
- cancellation π
- Keeps a turn that the client abandoned from losing what it had already streamed.
- round π
- One tool-call round: running the calls the server answers, storing each beside its output, and handing the roundβs items on to the next request.
- text_
response π - Streaming a text answer to the learner, and handing it to the turn once Azure has finished it.
EnumsΒ§
- Turn
Start π - What starts a turn: a new message from the user, or one resuming after the client answered a tool call the previous turn suspended on.
ConstantsΒ§
- MAX_
TOOL_ πCALL_ ROUNDS_ PER_ TURN - How many LLM requests one turn may make, bounding a model that keeps calling tools instead of answering.
FunctionsΒ§
- answer_
tool_ call_ and_ resume_ stream - Records a clientβs answer to a tool call the turn suspended on, and continues that turn once nothing else is outstanding.
- begin_
turn π - Shared preamble of both ways a turn can begin: acquire a connection, repair any tool call a dead turn of this conversation left unanswered, build the request the turn runs with, and hand off to stream_turn β or, on a resume that is still waiting on another call, return the ChatbotChatStreamEvent::Suspended stream without ever reaching it.
- recover_
and_ πsummarize - Builds the wire event for a round-ending error, folding in the input summary and response ids every call site of recover_from_round_error otherwise repeats.
- recover_
from_ πround_ error - What a round that ended in error becomes: logs it, answers whatever tool call the turn left without an output, and either returns the wire event for an error the turn survives or the original error for one that ends it.
- report_
stream_ πfailure - Records a failure that killed a turn in
error_variants/error_occurrences. - send_
chat_ request_ and_ parse_ stream - Starts a turn for a new user message, and streams its NDJSON events to the client.
- stream_
failure_ πdetails - What every chatbot stream failure records beyond its message, so one query finds them all and each row says which turn it belongs to.
- stream_
turn π - Runs the request rounds of one turn against the LLM and streams its events as NDJSON.