zeroclaw/src/agent
Edvard 0e5a785015 fix(agent): use native format for tool result history in run_tool_call_loop
When use_native_tools is true, the agent loop now:
- Formats assistant history as JSON with tool_calls array (matching
  what convert_messages() expects to reconstruct NativeMessage)
- Pushes each tool result as ChatMessage::tool with tool_call_id
  (instead of a single ChatMessage::user with XML tool_result tags)
- Adds fallback parsing for markdown code block tool calls
  (```tool_call ... ``` and hybrid ```tool_call ... </tool_call>)

Without this, the second LLM call (sending tool results back) gets
rejected with 4xx by OpenRouter/Gemini because the message format
doesn't match the OpenAI tool calling API expectations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 10:15:46 +08:00
..
agent.rs Merge branch 'main' into pr-484-clean 2026-02-17 08:54:24 -05:00
dispatcher.rs feat: add agent structure and improve tooling for provider 2026-02-17 01:01:56 +08:00
loop_.rs fix(agent): use native format for tool result history in run_tool_call_loop 2026-02-18 10:15:46 +08:00
memory_loader.rs feat(memory): add session_id isolation to Memory trait (#530) 2026-02-17 07:44:05 -05:00
mod.rs test(agent): add comprehensive loop test suite 2026-02-18 00:26:31 +08:00
prompt.rs feat: add agent structure and improve tooling for provider 2026-02-17 01:01:56 +08:00
tests.rs test(agent): add comprehensive loop test suite 2026-02-18 00:26:31 +08:00