fix: address panic due to possible `nil` map (#1348)

Andrey Nering created

Change summary

internal/agent/coordinator.go | 3 +++
1 file changed, 3 insertions(+)

Detailed changes

internal/agent/coordinator.go 🔗

@@ -654,6 +654,9 @@ func (c *coordinator) isAnthropicThinking(model config.SelectedModel) bool {
 
 func (c *coordinator) buildProvider(providerCfg config.ProviderConfig, model config.SelectedModel) (fantasy.Provider, error) {
 	headers := maps.Clone(providerCfg.ExtraHeaders)
+	if headers == nil {
+		headers = make(map[string]string)
+	}
 
 	// handle special headers for anthropic
 	if providerCfg.Type == anthropic.Name && c.isAnthropicThinking(model) {