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:
ParthSareen
2026-01-04 02:49:26 -08:00
parent 5c0caaff86
commit 5e23c4f2f7
3 changed files with 433 additions and 7 deletions

View File

@@ -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