Fix browser closure timing in search agent

Move defer statement to ensure browser closure occurs only after assigning the browser to the context. This prevents potential issues of premature resource release.
This commit is contained in:
2025-04-12 02:22:10 -04:00
parent 7a77d74624
commit 1be5cc047c
6 changed files with 51 additions and 20 deletions

View File

@@ -55,7 +55,6 @@ Here is the knowledge I have gathered from ` + fmt.Sprint(len(sources)) + ` sour
res, err := a.WithSystemPrompt(systemPrompt).
WithSystemPromptSuffix(``).
WithToolbox(nil).
CallAndExecute(ctx)
if err != nil {
return "", err
@@ -102,7 +101,6 @@ The moon is 4.5 billion years old [1,2], 238,855 miles away from the Earth [3],
res, err = a.WithSystemPrompt(systemPrompt).
WithSystemPromptSuffix(``).
WithToolbox(nil).
CallAndExecute(ctx, gollm.Message{Role: gollm.RoleSystem, Text: providedIntel}, summarizedData)
if err != nil {