MCPcopy Create free account
hub / github.com/docker/docker-agent / TestFallbackNoRetryOnNonRetryableError

Function TestFallbackNoRetryOnNonRetryableError

pkg/runtime/fallback_test.go:134–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

132}
133
134func TestFallbackNoRetryOnNonRetryableError(t *testing.T) {
135 t.Parallel()
136
137 synctest.Test(t, func(t *testing.T) {
138 primary := &failingProvider{id: "primary/auth-fail", err: errors.New("401 unauthorized")}
139 successStream := newStreamBuilder().
140 AddContent("Should not see this").
141 AddStopWithUsage(10, 5).
142 Build()
143 fallback := &mockProvider{id: "fallback/success", stream: successStream}
144
145 root := agent.New("root", "test",
146 agent.WithModel(primary),
147 agent.WithFallbackModel(fallback),
148 )
149
150 tm := team.New(team.WithAgents(root))
151 rt, err := NewLocalRuntime(t.Context(), tm, WithSessionCompaction(false), WithModelStore(mockModelStore{}))
152 require.NoError(t, err)
153
154 sess := session.New(session.WithUserMessage("test"))
155 sess.Title = "Non-Retryable Test"
156
157 var gotError, gotFallbackContent bool
158 for ev := range rt.RunStream(t.Context(), sess) {
159 if _, ok := ev.(*ErrorEvent); ok {
160 gotError = true
161 }
162 if choice, ok := ev.(*AgentChoiceEvent); ok && choice.Content == "Should not see this" {
163 gotFallbackContent = true
164 }
165 }
166 assert.True(t, gotFallbackContent || gotError, "should either get fallback content or error")
167 })
168}
169
170func TestFallbackRetriesWithBackoff(t *testing.T) {
171 t.Parallel()

Callers

nothing calls this directly

Calls 15

RunStreamMethod · 0.95
NewFunction · 0.92
WithModelFunction · 0.92
WithFallbackModelFunction · 0.92
NewFunction · 0.92
WithAgentsFunction · 0.92
NewFunction · 0.92
WithUserMessageFunction · 0.92
newStreamBuilderFunction · 0.85
NewLocalRuntimeFunction · 0.85
WithSessionCompactionFunction · 0.85
WithModelStoreFunction · 0.85

Tested by

no test coverage detected