@@ -349,9 +349,8 @@ func (a *sessionAgent) Run(ctx context.Context, call SessionAgentCall) (*ai.Agen
349349 return result, err
350350 }
351351 toolCalls := currentAssistant.ToolCalls()
352− toolResults := currentAssistant.ToolResults()
353352 // INFO: we use the parent context here because the genCtx has been cancelled
354− msgs, createErr := a.messages.List(ctx, currentSession.ID)
353+ msgs, createErr := a.messages.List(ctx, currentAssistant.SessionID)
355354 if createErr != nil {
356355 return nil, createErr
357356 }
@@ -359,13 +358,13 @@ func (a *sessionAgent) Run(ctx context.Context, call SessionAgentCall) (*ai.Agen
359358 if !tc.Finished {
360359 tc.Finished = true
361360 tc.Input = "{}"
361+ currentAssistant.AddToolCall(tc)
362362 }
363− currentAssistant.AddToolCall(tc)
364363
365364 found := false
366365 for _, msg := range msgs {
367366 if msg.Role == message.Tool {
368− for _, tr := range toolResults {
367+ for _, tr := range msg.ToolResults() {
369368 if tr.ToolCallID == tc.ID {
370369 found = true
371370 break