Status: done
Implemented by subagent and locally verified.
Commands:
uv run pytest tests/test_debug_runtime.py tests/test_websocket_api.py
uv run pytest
Results:
7 passed, 1 warning in 0.23s10 passed, 1 warning in 0.24sEvaluation note: the remaining work is cleanup and closeout. The warning is from FastAPI/Starlette TestClient importing the currently installed httpx version and does not block the MVP.
Make multi-turn tool-call history compatible with strict OpenAI Chat Completions compatible providers.
After the model emits a tool call, the next Chat Completions request should include:
tool_calls;tool reply message.Current runtime appends assistant content and tool replies, but it does not preserve assistant tool_calls. Some providers reject this because a tool message lacks a preceding assistant tool call.
This todo covers:
tool_calls in ChatMessage.ToolCallEvent.DebugRuntime to append assistant tool_calls before tool replies.tool_calls.This todo does not cover:
src/agent_lab/domain/messages.pysrc/agent_lab/application/runtime.pysrc/agent_lab/infrastructure/chat_client.py only if serialization needs adjustment.tests/test_debug_runtime.py and/or tests/test_websocket_api.py.docs/plans/todos.md.Add optional tool_calls to ChatMessage as a list of OpenAI-compatible tool call dicts. Keep content as a string for simplicity; use the aggregated assistant text or "" when a model emits only tool calls.
For each ToolCallEvent, create this message shape:
{
"id": event.id,
"type": "function",
"function": {
"name": event.name,
"arguments": event.raw_arguments,
},
}
At the end of each model turn, append one assistant message with aggregated content and all tool calls from that turn, then append the generated tool replies.
tool_callstool_call_idtool_calls to ChatMessage.DebugRuntime.run() to collect tool calls per model turn and append them to the assistant message before tool replies.OpenAICompatibleChatClient serializes tool_calls through model_dump(exclude_none=True); adjust only if needed.Run:
uv run pytest tests/test_debug_runtime.py tests/test_websocket_api.py
uv run pytest
Expected result:
tool_calls precede tool replies.