@@ -144,7 +144,6 @@ type AgentCall struct {
144144 PresencePenalty * float64 `json:"presence_penalty"`
145145 FrequencyPenalty * float64 `json:"frequency_penalty"`
146146 ActiveTools []string `json:"active_tools"`
147- Headers map [string ]string
148147 ProviderOptions ProviderOptions
149148 OnRetry OnRetryCallback
150149 MaxRetries * int
@@ -336,10 +335,6 @@ func (a *agent) prepareCall(call AgentCall) AgentCall {
336335 maps .Copy (headers , a .settings .headers )
337336 }
338337
339- if call .Headers != nil {
340- maps .Copy (headers , call .Headers )
341- }
342- call .Headers = headers
343338 return call
344339}
345340
@@ -420,7 +415,6 @@ func (a *agent) Generate(ctx context.Context, opts AgentCall) (*AgentResult, err
420415 FrequencyPenalty : opts .FrequencyPenalty ,
421416 Tools : preparedTools ,
422417 ToolChoice : & stepToolChoice ,
423- Headers : opts .Headers ,
424418 ProviderOptions : opts .ProviderOptions ,
425419 })
426420 })
@@ -747,7 +741,6 @@ func (a *agent) Stream(ctx context.Context, opts AgentStreamCall) (*AgentResult,
747741 PresencePenalty : opts .PresencePenalty ,
748742 FrequencyPenalty : opts .FrequencyPenalty ,
749743 ActiveTools : opts .ActiveTools ,
750- Headers : opts .Headers ,
751744 ProviderOptions : opts .ProviderOptions ,
752745 MaxRetries : opts .MaxRetries ,
753746 StopWhen : opts .StopWhen ,
@@ -838,7 +831,6 @@ func (a *agent) Stream(ctx context.Context, opts AgentStreamCall) (*AgentResult,
838831 FrequencyPenalty : call .FrequencyPenalty ,
839832 Tools : preparedTools ,
840833 ToolChoice : & stepToolChoice ,
841- Headers : call .Headers ,
842834 ProviderOptions : call .ProviderOptions ,
843835 }
844836
@@ -994,9 +986,8 @@ func (a *agent) createPrompt(system, prompt string, messages []Message, files ..
994986 if system != "" {
995987 preparedPrompt = append (preparedPrompt , NewSystemMessage (system ))
996988 }
997-
998- preparedPrompt = append (preparedPrompt , NewUserMessage (prompt , files ... ))
999989 preparedPrompt = append (preparedPrompt , messages ... )
990+ preparedPrompt = append (preparedPrompt , NewUserMessage (prompt , files ... ))
1000991 return preparedPrompt , nil
1001992}
1002993
@@ -1077,6 +1068,11 @@ func (a *agent) processStepStream(ctx context.Context, stream StreamResponse, op
10771068
10781069 activeToolCalls := make (map [string ]* ToolCallContent )
10791070 activeTextContent := make (map [string ]string )
1071+ type reasoningContent struct {
1072+ content string
1073+ options ProviderMetadata
1074+ }
1075+ activeReasoningContent := make (map [string ]reasoningContent )
10801076
10811077 // Process stream parts
10821078 for part := range stream {
@@ -1134,7 +1130,7 @@ func (a *agent) processStepStream(ctx context.Context, stream StreamResponse, op
11341130 }
11351131
11361132 case StreamPartTypeReasoningStart :
1137- activeTextContent [part .ID ] = ""
1133+ activeReasoningContent [part .ID ] = reasoningContent { content : "" }
11381134 if opts .OnReasoningStart != nil {
11391135 err := opts .OnReasoningStart (part .ID )
11401136 if err != nil {
@@ -1143,8 +1139,10 @@ func (a *agent) processStepStream(ctx context.Context, stream StreamResponse, op
11431139 }
11441140
11451141 case StreamPartTypeReasoningDelta :
1146- if _ , exists := activeTextContent [part .ID ]; exists {
1147- activeTextContent [part .ID ] += part .Delta
1142+ if active , exists := activeReasoningContent [part .ID ]; exists {
1143+ active .content += part .Delta
1144+ active .options = part .ProviderMetadata
1145+ activeReasoningContent [part .ID ] = active
11481146 }
11491147 if opts .OnReasoningDelta != nil {
11501148 err := opts .OnReasoningDelta (part .ID , part .Delta )
@@ -1154,21 +1152,19 @@ func (a *agent) processStepStream(ctx context.Context, stream StreamResponse, op
11541152 }
11551153
11561154 case StreamPartTypeReasoningEnd :
1157- if text , exists := activeTextContent [part .ID ]; exists {
1158- stepContent = append (stepContent , ReasoningContent {
1159- Text : text ,
1160- ProviderMetadata : part .ProviderMetadata ,
1161- })
1155+ if active , exists := activeReasoningContent [part .ID ]; exists {
1156+ content := ReasoningContent {
1157+ Text : active .content ,
1158+ ProviderMetadata : active .options ,
1159+ }
1160+ stepContent = append (stepContent , content )
11621161 if opts .OnReasoningEnd != nil {
1163- err := opts .OnReasoningEnd (part .ID , ReasoningContent {
1164- Text : text ,
1165- ProviderMetadata : part .ProviderMetadata ,
1166- })
1162+ err := opts .OnReasoningEnd (part .ID , content )
11671163 if err != nil {
11681164 return StepResult {}, false , err
11691165 }
11701166 }
1171- delete (activeTextContent , part .ID )
1167+ delete (activeReasoningContent , part .ID )
11721168 }
11731169
11741170 case StreamPartTypeToolInputStart :
0 commit comments