ion7-llm / tools.loop

module

tools.loop

Functions

M.run

Run the tool-use loop until the model returns a content-only turn or `max_turns` is exceeded. The dispatch path is : - call `engine:chat(session, { tools = toolset })` ; - if the response carries `tool_calls`, append the assistant message (with thinking + tool_calls preserved) to the session, then for each call resolve the matching tool from the `ToolSet`, dispatch its `handler`, append the result as a tool message ; - loop, with the next chat turn re-rendering the augmented history through the chat template.

M.run(engine, session, opts)
engineion7.llm.Engine
sessionion7.llm.Session
optstable
→ ion7.llm.ResponseThe final content-only response.
→ integerNumber of dispatch rounds executed.