Changeset 0.23.0 (#153)
This commit is contained in:
@@ -235,6 +235,20 @@ func (p *AnthropicProvider) doRequest(ctx context.Context, cfg ProviderConfig, r
|
||||
|
||||
antMsg := anthropicMessage{Role: m.Role}
|
||||
|
||||
// ── Foreign persona rewrite (v0.23.0) ──
|
||||
// Anthropic doesn't support the "name" field on messages.
|
||||
// Rewrite named assistant messages (from other personas) to user
|
||||
// role with attribution so Anthropic maintains alternation and
|
||||
// the model understands it's a multi-participant conversation.
|
||||
if m.Role == "assistant" && m.Name != "" {
|
||||
antMsg.Role = "user"
|
||||
antMsg.Content = []anthropicContentBlock{
|
||||
{Type: "text", Text: fmt.Sprintf("[%s responded:]\n%s", m.Name, m.Content)},
|
||||
}
|
||||
messages = append(messages, antMsg)
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Role == "assistant" && len(m.ToolCalls) > 0 {
|
||||
// Assistant with tool calls → mixed content blocks
|
||||
if m.Content != "" {
|
||||
@@ -372,7 +386,7 @@ func (p *AnthropicProvider) doRequest(ctx context.Context, cfg ProviderConfig, r
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := http.DefaultClient.Do(httpReq)
|
||||
resp, err := cfg.Client().Do(httpReq)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("provider request: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user