01
Tool calling as an explicit graph — and streaming both tokens, not just text
- Problem
- With a black-box agent executor you can't see why the model chose a tool, and a chat UI that only streams text can't show that a tool is running — the interface goes silent exactly when the agent is doing the most interesting thing.
- Decision
- The agent is a LangGraph StateGraph: model node, conditional edge to a tools node, tools back to the model, until a final answer. The server exposes the same run over SSE, emitting typed events — token, tool_start, tool_end — so the client renders tool activity as first-class UI, not as text the model happened to write.
- Tradeoff
- Graph nodes mean the agent's control flow is code I own and must maintain, including the loop guards that stop a model from calling tools forever. The alternative — a one-line executor — would have hidden precisely the part I wanted to understand.
- Outcome
- Every answer is explainable: the transcript shows which tools ran, with what input, in what order, and the state diagram in the UI lights up with the same sequence.