(t *testing.T)
| 276 | } |
| 277 | |
| 278 | func TestAdvisorToolReportsNestedError(t *testing.T) { |
| 279 | t.Parallel() |
| 280 | |
| 281 | runtime, err := chatadvisor.NewRuntime(chatadvisor.RuntimeConfig{ |
| 282 | Model: &chattest.FakeModel{ |
| 283 | ProviderName: "test-provider", |
| 284 | ModelName: "test-model", |
| 285 | StreamFn: func(_ context.Context, _ fantasy.Call) (fantasy.StreamResponse, error) { |
| 286 | return nil, xerrors.New("boom") |
| 287 | }, |
| 288 | }, |
| 289 | MaxUsesPerRun: 1, |
| 290 | MaxOutputTokens: 64, |
| 291 | }) |
| 292 | require.NoError(t, err) |
| 293 | |
| 294 | tool := chatadvisor.Tool(chatadvisor.ToolOptions{ |
| 295 | Runtime: runtime, |
| 296 | GetConversationSnapshot: func() []fantasy.Message { return nil }, |
| 297 | }) |
| 298 | |
| 299 | resp := runAdvisorTool(t, tool, chatadvisor.AdvisorArgs{Question: "why?"}) |
| 300 | require.False(t, resp.IsError) |
| 301 | |
| 302 | var result chatadvisor.AdvisorResult |
| 303 | require.NoError(t, json.Unmarshal([]byte(resp.Content), &result)) |
| 304 | require.Equal(t, chatadvisor.ResultTypeError, result.Type) |
| 305 | require.Contains(t, result.Error, "boom") |
| 306 | require.Empty(t, result.Advice) |
| 307 | require.Empty(t, result.AdvisorModel) |
| 308 | // A failed nested run does not consume the per-run quota. |
| 309 | require.Equal(t, 1, result.RemainingUses) |
| 310 | } |
| 311 | |
| 312 | func TestAdvisorToolReportsLimitReached(t *testing.T) { |
| 313 | t.Parallel() |
nothing calls this directly
no test coverage detected