Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
golang.org/x/oauth2 v0.33.0
golang.org/x/perf v0.0.0-20251008221758-42ba72fec400
golang.org/x/sync v0.18.0
golang.org/x/sys v0.38.0
golang.org/x/sys v0.40.0
golang.org/x/tools v0.38.0
google.golang.org/api v0.257.0
google.golang.org/appengine/v2 v2.0.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1826,8 +1826,8 @@ golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/telemetry v0.0.0-20251014153721-24f779f6aaef h1:5xFtU4tmJMJSxSeDlr1dgBff2tDXrq0laLdS1EA3LYw=
golang.org/x/telemetry v0.0.0-20251014153721-24f779f6aaef/go.mod h1:Pi4ztBfryZoJEkyFTI5/Ocsu2jXyDr6iSdgJiYE/uwE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down
19 changes: 18 additions & 1 deletion pkg/aflow/llm_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"fmt"
"maps"
"reflect"
"strings"
"time"

"github.com/google/syzkaller/pkg/aflow/trajectory"
"google.golang.org/genai"
Expand Down Expand Up @@ -98,7 +100,7 @@ func (a *LLMAgent) chat(ctx *Context, cfg *genai.GenerateContentConfig, tools ma
if err := ctx.startSpan(reqSpan); err != nil {
return "", nil, err
}
resp, err := ctx.generateContent(cfg, req)
resp, err := a.generateContent(ctx, cfg, req)
if err != nil {
return "", nil, ctx.finishSpan(reqSpan, err)
}
Expand Down Expand Up @@ -216,6 +218,21 @@ func (a *LLMAgent) parseResponse(resp *genai.GenerateContentResponse) (
return
}

func (a *LLMAgent) generateContent(ctx *Context, cfg *genai.GenerateContentConfig,
req []*genai.Content) (*genai.GenerateContentResponse, error) {
backoff := time.Second
for try := 0; ; try++ {
resp, err := ctx.generateContent(cfg, req)
if err != nil && try < 100 &&
strings.Contains(err.Error(), "Error 503, Message: The model is overloaded. Please try again later.") {
time.Sleep(backoff)
backoff = min(backoff+time.Second, 10*time.Second)
continue
}
return resp, err
}
}

func (a *LLMAgent) verify(vctx *verifyContext) {
vctx.requireNotEmpty(a.Name, "Name", a.Name)
vctx.requireNotEmpty(a.Name, "Reply", a.Reply)
Expand Down