Skip to main content

Module turn

Module turn 

Source
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Β§

TurnStart πŸ”’
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.