RAG & Agents Engineering

M22 lab, the agent loop and tool calling

A tool error is either a message or a crash.

Larkspur Cloud’s support agent has two tools: search_handbook over the twelve handbook chunks from M10 (real TF-IDF) and get_server_status. Pick a question and a handle_tool_errors setting for the ToolNode: the trace shows every message the loop adds, and where a run stops.

Customer question
ToolNode setting, handle_tool_errors
Messages in state
Tool calls
Errors the model read
Outcome

The message trace

State after the run

#MessageContent

Tool results and error texts are what LangGraph 1.2 produces for these calls, checked in Python. The model’s turns are scripted and representative: a real model chooses its own words and arguments.

All four questions at this setting

QuestionOutcomeMessagesErrors read
Answered

A crashed run returns nothing to the customer: graph.invoke raises, and the messages so far are lost unless you checkpoint them.