Execute all tool calls from one Ollama response and append results to messages.
(
ctx: _AgentRunContext,
ollama_msg: Any,
)
| 456 | |
| 457 | |
| 458 | async def _process_ollama_tool_turn( |
| 459 | ctx: _AgentRunContext, |
| 460 | ollama_msg: Any, |
| 461 | ) -> None: |
| 462 | """Execute all tool calls from one Ollama response and append results to messages.""" |
| 463 | ctx.messages.append(_build_ollama_assistant_message(ollama_msg)) |
| 464 | for ollama_tool_call in ollama_msg.tool_calls: |
| 465 | tool_name = ollama_tool_call.function.name |
| 466 | tool_input = dict(ollama_tool_call.function.arguments) |
| 467 | result = await _execute_tool(tool_name, tool_input, ctx.on_tool_call) |
| 468 | ctx.tool_calls.append(ToolCall(name=tool_name, input=tool_input, result=result)) |
| 469 | logger.info("Ollama tool executed: %s → %d chars", tool_name, len(result)) |
| 470 | ctx.messages.append({"role": "tool", "content": result}) |
| 471 | |
| 472 | |
| 473 | # --------------------------------------------------------------------------- |
no test coverage detected