Repository navigation
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Harsh23Kashyap
left a comment
There was a problem hiding this comment.
Verified at b1a0097. The round trip works in both directions against a stub server, streaming and non-streaming: outbound history rewrites tool messages to the native shape (tool_name set, tool_call_id dropped, arguments sent as objects), inbound calls get runtime IDs with JSON-encoded arguments, malformed argument strings fail closed, and an incomplete stream publishes nothing.
Proof: all 12 Ollama tests pass in-tree at this head. Against current main the round trip does not exist: a response whose message carries only tool_calls errors with "no message in response", and tool-role history goes out with tool_call_id instead of tool_name. Both confirmed with direct probes on main.
LGTM.
Lynn-Inf
left a comment
There was a problem hiding this comment.
The fix is right: tool-only responses no longer trip the "no message in response" check, streaming publishes calls only after done, and the request side converts arguments to Ollama's object shape and uses tool_name for results.
One gap on the response side: ollamaToolCall.Function.Arguments decodes as map[string]any, so a server that returns OpenAI-style string arguments ("arguments": "{\"query\":\"x\"}") fails json.Unmarshal for the entire response. Before this change that field was not parsed at all, so the same request succeeded. The request path already accepts both shapes, so please mirror it here — decode Arguments as json.RawMessage and accept either an object or a JSON string (normalising an empty string to {}), then marshal to the internal form as you do today.
|
Verified this at b1a0097. On the response side ollamaToolCall.Function.Arguments is typed map[string]any, so a server that returns OpenAI-style string arguments fails the json.Unmarshal for the whole response, and before this change that field was ignored entirely so the same response went through. Real strictness regression for non-conforming servers. The request path (ollama.go:78-86) already accepts both shapes, so mirroring it with json.RawMessage and normalizing an empty string to {} is a small, symmetric fix. Worth taking before merge. |
Summary
Ollama tool calls are currently dropped from both streaming and non-streaming chat responses. Tool-only responses can also fail with "no message in response", preventing the agent from executing retrieval and other tools.
This change preserves returned tool calls, supplies IDs when Ollama omits them, and converts arguments between Ollama's JSON objects and the runtime's JSON strings. Follow-up requests send tool results using Ollama's tool_name field. Incomplete streams do not publish tool calls.
Validation
bash build.sh --cppandbash build.sh --test ./internal/entity/models/...in the ARM64 Docker build environment; model package and native unit tests passed.