Skip to main content

answer_client_tool_call

Function answer_client_tool_call 

Source
pub async fn answer_client_tool_call(
    conn: &mut PgConnection,
    conversation_id: Uuid,
    tool_call_id: &str,
    output: String,
    client_answer: Option<Value>,
) -> ModelResult<ClientToolAnswerOutcome>
Expand description

Records the client’s answer to a tool call of a suspended turn and reports whether the turn may now resume. output is the answer in the form the LLM reads; client_answer is the payload the client sent, kept for callers that need the answer as data, and None when no client answer was applied.

Writing the answer and deciding who resumes happen in one transaction that holds the conversation lock, so of two clients answering different calls of the same round at the same time exactly one is told to resume, instead of both or neither. The lock is released by the commit, before any resumed request is made.

Errors with ModelErrorType::RecordNotFound when the conversation has no such call, and with ModelErrorType::InvalidRequest when the call is not one a client answers or already has an answer. Those are the client’s mistakes and no answer is written.