A minimal chat agent
skip_lemonade=True construction takes a few
milliseconds, and nothing is shared between two agents.
The four settings
GAIA adds one tool of its own,
read_tool_output, so the model can page through a
result too long to send whole. Pass
tool_scope=["get_order", "read_tool_output"] to refuse any call outside that list.
Reading the result
process_query() returns a dict. Decide what to show from status and
stop_reason, never from the text.
Your own model client
SubclassLLMClient and put it where the agent’s client sits. chat() returns the
model’s text, or tool_calls_reply(...) when the model called tools.
- Raise your own exceptions. GAIA catches them and ends the turn with
status: "failed"andstop_reason: "model_call". Keep the exception on your client if you need its type afterwards. - Accept
**kwargs. Besidesmessages,model,stream,toolsandmax_tokens, the loop can passtemperature,top_p,tool_choice,reasoning_effortandstop. Forward the ones your provider takes. - Use a model id with no provider prefix. Ids shaped like
provider.modelare looked up in Lemonade’s cloud catalogue, and an id it does not list gets its tools as text in the system prompt instead oftools=. - Return
finish_reason."length"on a tool call is how GAIA knows the call was cut off and asks for it again. - Return
usage. The result’s token counts andcost_usdare summed fromget_last_usage(), in the OpenAI shape. It must describe the most recent call only, or a step’s tokens are counted twice.
Testing
gaia.testing.ScriptedLLMClient runs the same loop with no network. See
Scripting the Model.
What stays your job
- Budgets.
max_stepsandmax_output_tokensare the limits the loop enforces. Dollar and wall-clock limits belong in your client, between calls. - Credentials. Read them from the environment in your client. GAIA’s OS keyring lookup is for desktops.
- Checking the reply. On a conversation host GAIA sends a reply back only when
it is malformed: a tool call or tool output written out as text. Two tries, then
the turn ends
incompletewithstop_reason: "tool_call_format". Whether the reply is true is yours to check: compare it withtool_callsbefore it reaches a customer. - Hooks you add still run. An
answer_problemsoverride, or a mixin such as memory, can still send the model back. Those show up inreprompts.