{"record":{"id":"6256e6a2f0c6ed46","repo":"mastra-ai/mastra","slug":"agent-learning-request-failed-response-status","errorCode":null,"errorMessage":"Agent Learning request failed (${response.status})","messagePattern":"Agent Learning request failed \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/playground-ui/src/ee/signals/trace-intelligence-context.ts","lineNumber":10,"sourceCode":"import { createContext } from 'react';\n\nimport type { LinkComponent } from '@/ds/types/link-component';\n\nexport type TraceIntelligenceRequest = <Response>(path: string) => Promise<Response>;\n\nasync function defaultRequest<Response>(path: string): Promise<Response> {\n  const response = await fetch(path, { credentials: 'include' });\n  if (!response.ok) {\n    throw new Error(`Agent Learning request failed (${response.status})`);\n  }\n  return response.json() as Promise<Response>;\n}\n\nexport interface TraceIntelligenceContextValue {\n  cacheScope: string;\n  request: TraceIntelligenceRequest;\n  LinkComponent: LinkComponent;\n  getTraceHref: (traceId: string) => string;\n}\n\nexport const defaultTraceIntelligenceContextValue: TraceIntelligenceContextValue = {\n  cacheScope: 'oss-studio',\n  request: defaultRequest,\n  LinkComponent: 'a',\n  getTraceHref: traceId => `/traces?traceId=${encodeURIComponent(traceId)}`,\n};\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/playground-ui/src/ee/signals/trace-intelligence-context.ts#L1-L28","documentation":"defaultRequest is the fetch wrapper used by the Agent Learning / Trace Intelligence context in the playground UI. It calls fetch with credentials included and throws this error whenever the HTTP response status is not ok (e.g. 404, 401, 500), since the API endpoint did not return a usable response. The thrown Error discards the response body, so only the numeric status is reported.","triggerScenarios":"Any call to the TraceIntelligenceRequest function where fetch(path, { credentials: 'include' }) resolves with response.ok === false — e.g. the Agent Learning API route is missing, the server returns 401/403 because the user is not authenticated, or a 500 from a backend failure.","commonSituations":"Running the playground against a server that does not have the Agent Learning routes registered (older server version), an expired or missing session cookie causing 401, or a transient server error (500/502) behind a proxy.","solutions":["Check the reported HTTP status in the message and inspect the corresponding server logs for the failing endpoint.","Verify the playground and server versions match so the Agent Learning API routes exist (404).","Confirm you are logged in / session cookie is valid (401/403); re-authenticate.","Retry the request if the status is 5xx, as it may be a transient backend failure."],"exampleFix":"// before\nconst data = await request('/api/agent-learning/summary');\n\n// after\ntry {\n  const data = await request('/api/agent-learning/summary');\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Agent Learning request failed')) {\n    showAgentLearningUnavailableNotice();\n  } else {\n    throw e;\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const data = await request<Response>(path);\n} catch (e) {\n  const status = e instanceof Error ? /\\((\\d+)\\)$/.exec(e.message)?.[1] : undefined;\n  if (status === '401' || status === '403') redirectToLogin();\n  else showFallbackUi();\n}","preventionTips":["Keep playground and server versions in sync so Agent Learning routes exist.","Ensure the user session is valid before mounting the Trace Intelligence context.","Log the status code and handle 4xx vs 5xx differently in your UI."],"tags":["network","http","fetch","playground-ui","agent-learning"],"backgroundTag":"http-request-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}