Make LLM call using the fallback handler.Note: This function expects the caller (sample_step) to have validated that
sampling_handler is set via determine_handler_mode(). The checks below are
safeguards against internal misuse.
tool_calls: List of tool use requests from the LLM.
tool_map: Mapping from tool name to SamplingTool.
mask_error_details: If True, mask detailed error messages from tool execution.
When masked, only generic error messages are returned to the LLM.
Tools can explicitly raise ToolError to bypass masking when they want
to provide specific error messages to the LLM.
Create a synthetic ‘final_response’ tool for structured output.This tool is used to capture structured responses from the LLM.
The tool’s schema is derived from the result_type.
Implementation of Context.sample_step().Make a single LLM sampling call. This is a stateless function that makes
exactly one LLM call and optionally executes any requested tools.
Implementation of Context.sample().Send a sampling request to the client and await the response. This method
runs to completion automatically, executing a tool loop until the LLM
provides a final text response.