Skip to main content

check_client_tool_call

Function check_client_tool_call 

Source
pub async fn check_client_tool_call(
    conn: &mut PgConnection,
    user_context: &ChatbotTurnContext,
    tool_name: &str,
    arguments: &str,
) -> ChatbotResult<Result<(), ClientToolCallRefusal>>
Expand description

Checks that a client tool call can go ahead: its arguments parse, and its caller may make it against what those arguments target.

Called both before the turn suspends on the call and when its answer arrives, since nothing bounds how long a call waits and a role can be revoked while it does. A ClientToolCallRefusal is not a failure: the caller turns it into an explanation the model reads, because the turn stays stuck until its call has some output.

Fails with ChatbotErrorType::InvalidToolArguments for a call the tool would reject, which can never be answered and so has to fail while the turn can still report it to the LLM, and with ChatbotErrorType::InvalidToolName when no client tool goes by tool_name.