(t *testing.T)
| 310 | } |
| 311 | |
| 312 | func TestAdvisorToolReportsLimitReached(t *testing.T) { |
| 313 | t.Parallel() |
| 314 | |
| 315 | runtime, err := chatadvisor.NewRuntime(chatadvisor.RuntimeConfig{ |
| 316 | Model: &chattest.FakeModel{ |
| 317 | ProviderName: "test-provider", |
| 318 | ModelName: "test-model", |
| 319 | StreamFn: func(_ context.Context, _ fantasy.Call) (fantasy.StreamResponse, error) { |
| 320 | return streamFromParts([]fantasy.StreamPart{ |
| 321 | {Type: fantasy.StreamPartTypeTextStart, ID: "text-1"}, |
| 322 | {Type: fantasy.StreamPartTypeTextDelta, ID: "text-1", Delta: "first"}, |
| 323 | {Type: fantasy.StreamPartTypeTextEnd, ID: "text-1"}, |
| 324 | {Type: fantasy.StreamPartTypeFinish, FinishReason: fantasy.FinishReasonStop}, |
| 325 | }), nil |
| 326 | }, |
| 327 | }, |
| 328 | MaxUsesPerRun: 1, |
| 329 | MaxOutputTokens: 64, |
| 330 | }) |
| 331 | require.NoError(t, err) |
| 332 | |
| 333 | tool := chatadvisor.Tool(chatadvisor.ToolOptions{ |
| 334 | Runtime: runtime, |
| 335 | GetConversationSnapshot: func() []fantasy.Message { return nil }, |
| 336 | }) |
| 337 | |
| 338 | first := runAdvisorTool(t, tool, chatadvisor.AdvisorArgs{Question: "first?"}) |
| 339 | require.False(t, first.IsError) |
| 340 | |
| 341 | second := runAdvisorTool(t, tool, chatadvisor.AdvisorArgs{Question: "second?"}) |
| 342 | require.False(t, second.IsError) |
| 343 | |
| 344 | var result chatadvisor.AdvisorResult |
| 345 | require.NoError(t, json.Unmarshal([]byte(second.Content), &result)) |
| 346 | require.Equal(t, chatadvisor.ResultTypeLimitReached, result.Type) |
| 347 | require.Equal(t, 0, result.RemainingUses) |
| 348 | require.Empty(t, result.Advice) |
| 349 | require.Empty(t, result.Error) |
| 350 | require.Empty(t, result.AdvisorModel) |
| 351 | } |
| 352 | |
| 353 | func TestAdvisorToolReportsEmptyModelOutput(t *testing.T) { |
| 354 | t.Parallel() |
nothing calls this directly
no test coverage detected