@@ -137,18 +137,16 @@ func (i *BlockingInterception) ProcessRequest(w http.ResponseWriter, r *http.Req
137137
138138 // Capture any thinking blocks that were returned.
139139 var thoughtRecords []* recorder.ModelThoughtRecord
140- if ! i .isSmallFastModel () {
141- for _ , block := range resp .Content {
142- switch variant := block .AsAny ().(type ) {
143- case anthropic.ThinkingBlock :
144- thoughtRecords = append (thoughtRecords , & recorder.ModelThoughtRecord {
145- InterceptionID : i .ID ().String (),
146- Content : variant .Thinking ,
147- })
148- case anthropic.RedactedThinkingBlock :
149- // For redacted thinking, there's nothing useful we can capture.
150- continue
151- }
140+ for _ , block := range resp .Content {
141+ switch variant := block .AsAny ().(type ) {
142+ case anthropic.ThinkingBlock :
143+ thoughtRecords = append (thoughtRecords , & recorder.ModelThoughtRecord {
144+ Content : variant .Thinking ,
145+ CreatedAt : time .Now (),
146+ })
147+ case anthropic.RedactedThinkingBlock :
148+ // For redacted thinking, there's nothing useful we can capture.
149+ continue
152150 }
153151 }
154152
@@ -173,22 +171,15 @@ func (i *BlockingInterception) ProcessRequest(w http.ResponseWriter, r *http.Req
173171 Tool : toolUse .Name ,
174172 Args : toolUse .Input ,
175173 Injected : false ,
174+ ModelThoughts : thoughtRecords ,
176175 })
177-
178- // Associate the model thoughts with this tool call.
179- for _ , thought := range thoughtRecords {
180- thought .ProviderToolCallID = toolUse .ID
181- }
176+ // Clear after first use to avoid duplicating across
177+ // multiple tool calls in the same message.
178+ thoughtRecords = nil
182179 }
183180
184- // If no injected tool calls, persist thoughts and we're done.
181+ // If no injected tool calls, we're done.
185182 if len (pendingToolCalls ) == 0 {
186- for _ , thought := range thoughtRecords {
187- if thought .ProviderToolCallID == "" {
188- continue
189- }
190- _ = i .recorder .RecordModelThought (ctx , thought )
191- }
192183 break
193184 }
194185
@@ -223,12 +214,11 @@ func (i *BlockingInterception) ProcessRequest(w http.ResponseWriter, r *http.Req
223214 Args : tc .Input ,
224215 Injected : true ,
225216 InvocationError : err ,
217+ ModelThoughts : thoughtRecords ,
226218 })
227-
228- // Associate the model thoughts with this tool call.
229- for _ , thought := range thoughtRecords {
230- thought .ProviderToolCallID = tc .ID
231- }
219+ // Clear after first use to avoid duplicating across
220+ // multiple tool calls in the same message.
221+ thoughtRecords = nil
232222
233223 if err != nil {
234224 // Always provide a tool_result even if the tool call failed
@@ -315,14 +305,6 @@ func (i *BlockingInterception) ProcessRequest(w http.ResponseWriter, r *http.Req
315305 }
316306 }
317307
318- // Only persist thoughts that are associated to a tool call.
319- for _ , thought := range thoughtRecords {
320- if thought .ProviderToolCallID == "" {
321- continue
322- }
323- _ = i .recorder .RecordModelThought (ctx , thought )
324- }
325-
326308 // Sync the raw payload with updated messages so that withBody()
327309 // sends the updated payload on the next iteration.
328310 if err := i .syncPayloadMessages (messages .Messages ); err != nil {
0 commit comments