mirror of
https://github.com/ollama/ollama.git
synced 2026-04-27 19:25:55 +02:00
fix: agent loop message handling and cloud model inheritance
- Fix tool result messages losing ToolName and ToolCallID fields - Include Thinking in intermediate assistant messages during tool loops - Inherit capabilities, remote config, and model family from base model when creating agents (fixes "does not support generate" for cloud models) - Add tests for tool message construction and message stitching 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
10
cmd/cmd.go
10
cmd/cmd.go
@@ -1665,10 +1665,11 @@ func chat(cmd *cobra.Command, opts runOptions) (*api.Message, error) {
|
||||
// Execute tool calls and continue the conversation
|
||||
fmt.Fprintf(os.Stderr, "\n")
|
||||
|
||||
// Add assistant's tool call message to history
|
||||
// Add assistant's tool call message to history (include thinking for proper rendering)
|
||||
assistantMsg := api.Message{
|
||||
Role: "assistant",
|
||||
Content: fullResponse.String(),
|
||||
Thinking: thinkingContent.String(),
|
||||
ToolCalls: pendingToolCalls,
|
||||
}
|
||||
messages = append(messages, assistantMsg)
|
||||
@@ -1727,11 +1728,8 @@ func chat(cmd *cobra.Command, opts runOptions) (*api.Message, error) {
|
||||
fmt.Fprintf(os.Stderr, "Output:\n%s\n", result.Content)
|
||||
}
|
||||
|
||||
// Add tool result to messages
|
||||
toolResults = append(toolResults, api.Message{
|
||||
Role: "tool",
|
||||
Content: result.Content,
|
||||
})
|
||||
// Add tool result to messages (preserves ToolName, ToolCallID from result)
|
||||
toolResults = append(toolResults, result)
|
||||
}
|
||||
|
||||
// Add tool results to message history
|
||||
|
||||
Reference in New Issue
Block a user