Build a Grounded Python Teaching Assistant with Tool Calling
The article presents a Python tutorial for connecting a teaching assistant to local schedule, vocabulary, and learning-record tools. It implements both a manual tool-call loop and a LangGraph-based ReAct workflow, including tool schemas, friendly error handling, step limits, repeated-call detection, and 38 passing offline tests. The article opens by recounting a missed class and an incorrect vocabulary-level answer; these incidents are not independently corroborated in the supplied material.
The tutorial demonstrates how program-controlled tool execution can ground an assistant’s answers in application data while keeping validation, error handling, and loop termination under the application’s control.
上周出了一次挺丢人的事故。一个学生问助教小E:"我明天的课是几点?"小E秒回:"您的写作课在周三下午三点,3 号教室。"学生第二天下午三点到了 3 号教室——那天根本没排课,写作课是周六上午的。
另一个学生问"accord 这个词在你们词表里是几级",小E答得更有底气:"C1 级,考研核心词,建议精读。"实际上它在词表里是 B2,考研大纲里压根没有它。
学生白跑一趟还是小事。带队老师看了聊天记录问我:这模型是不是坏了?
模型没坏,它甚至表现得很"称职"——生成一句像模像样的回答本来就是它唯一会做的事。它没有我们的课表,没有我们的词表,你却要求它回答里面的问题,它只能拿训练时见过的模式补全一个"最像答案的文本"。前六篇我们一直在打磨它"怎么说",这一篇要解决的是更根本的问题:让它闭嘴去查。