Skip to main content

recover_from_round_error

Function recover_from_round_error 

Source
async fn recover_from_round_error(
    pool: &PgPool,
    conversation_id: Uuid,
    response_ids: &[String],
    input_summary: &str,
    error: ChatbotError,
) -> ChatbotResult<Bytes>
Expand description

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.

The reap belongs here rather than at each failing site, so that no error path can end a turn without it: a call with no output makes the LLM reject every later message of the conversation. response_ids are the responses this turn’s rounds were given, which keeps the reap off the calls of a turn streaming in another request.

Takes the pool rather than a connection: the call sites hold their round’s connection under a live borrow, or have already given theirs back, so this acquires its own for the reap.