{"record":{"id":"6c188125522a0107","repo":"vxcontrol/pentagi","slug":"failed-to-test-agent-w","errorCode":null,"errorMessage":"failed to test agent: %w","messagePattern":"failed to test agent: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/providers/providers.go","lineNumber":900,"sourceCode":"\t}\n\n\t// Create temporary provider for testing using existing provider logic\n\tproviderName := provider.ProviderName(\"test-provider\")\n\ttempProvider, err := pc.buildProviderFromConfig(prvtype, providerName, patchedConfig)\n\tif err != nil {\n\t\treturn result, fmt.Errorf(\"failed to create provider for testing: %w\", err)\n\t}\n\n\t// Run tests for specific agent type only\n\tresults, err := tester.TestProvider(\n\t\tctx,\n\t\ttempProvider,\n\t\ttester.WithAgentTypes(agentType),\n\t\ttester.WithVerbose(false),\n\t\ttester.WithParallelWorkers(defaultTestParallelWorkersNumber),\n\t)\n\tif err != nil {\n\t\treturn result, fmt.Errorf(\"failed to test agent: %w\", err)\n\t}\n\n\t// Extract results for the specific agent type\n\tswitch agentType {\n\tcase pconfig.OptionsTypeSimple:\n\t\tresult = results.Simple\n\tcase pconfig.OptionsTypeSimpleJSON:\n\t\tresult = results.SimpleJSON\n\tcase pconfig.OptionsTypePrimaryAgent:\n\t\tresult = results.PrimaryAgent\n\tcase pconfig.OptionsTypeAssistant:\n\t\tresult = results.Assistant\n\tcase pconfig.OptionsTypeGenerator:\n\t\tresult = results.Generator\n\tcase pconfig.OptionsTypeRefiner:\n\t\tresult = results.Refiner\n\tcase pconfig.OptionsTypeAdviser:\n\t\tresult = results.Adviser","sourceCodeStart":882,"sourceCodeEnd":918,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/providers/providers.go#L882-L918","documentation":"TestAgent runs tester.TestProvider against the temporary provider, limited to the requested agent type via tester.WithAgentTypes. If the test harness itself returns an error (setup failure, context cancellation, harness-internal error — not per-request model failures, which are recorded in results), it is wrapped as \"failed to test agent: %w\".","triggerScenarios":"tester.TestProvider returns an error: invalid test options, an unsupported agent type inside the tester, context deadline/cancellation during the test run, or a harness-level setup error (e.g. cannot enumerate tools for the agent type).","commonSituations":"Test context times out while the model call runs; passing an agent type the tester does not support; parallel worker configuration invalid; underlying LLM endpoint hangs until ctx deadline.","solutions":["Inspect the wrapped inner error for timeout vs harness-internal cause","Increase the context timeout or check network reachability to the LLM endpoint","Confirm the agent type passed to WithAgentTypes is supported by the tester package","Retry once to rule out a transient provider outage before deeper debugging"],"exampleFix":"// before\nctx := context.Background() // no deadline; hangs then fails\n// after\nctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)\ndefer cancel()\nresults, err := tester.TestProvider(ctx, tempProvider, tester.WithAgentTypes(agentType))","handlingStrategy":"try-catch","validationCode":"ctx, cancel := context.WithTimeout(ctx, 2*time.Minute)\ndefer cancel() // ensure adequate deadline before the test call","typeGuard":null,"tryCatchPattern":"result, err := ctrl.TestAgent(ctx, prvtype, agentType, cfg)\nif err != nil {\n    if errors.Is(err, context.DeadlineExceeded) || strings.Contains(err.Error(), \"failed to test agent\") {\n        return fmt.Errorf(\"agent test timed out or harness failed; retry or increase timeout: %w\", err)\n    }\n    return err\n}","preventionTips":["Set a generous context timeout on test calls (LLM latency is high)","Check LLM endpoint reachability before running tests","Only retry once for transient outages; per-model failures appear in results, not as this error","Keep the tester package's supported agent types in sync with pconfig"],"tags":["testing","timeout","llm"],"backgroundTag":"test-harness-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}