{"record":{"id":"dd981d36ae2721f1","repo":"Budibase/budibase","slug":"agent-log-details-not-ready","errorCode":null,"errorMessage":"Agent log details not ready","messagePattern":"Agent log details not ready","errorType":"http","errorClass":"HTTPError","httpStatus":404,"severity":"warning","filePath":"packages/server/src/sdk/workspace/ai/agentLogs/indexQueue.ts","lineNumber":108,"sourceCode":"  input: IndexAgentLogOperationInput\n): Promise<void> {\n  if (!input.agentId || !input.sessionId) {\n    return\n  }\n\n  let uniqueRequestIds = [...new Set(input.requestIds)].filter(Boolean)\n  if (!uniqueRequestIds.length) {\n    const { rows } = await fetchLiteLLMSessionRows(input.sessionId)\n    uniqueRequestIds = rows\n      .filter(\n        row => getLiteLLMRequestUser(row) === getExpectedEndUser(input.agentId)\n      )\n      .map(row => row.request_id)\n      .filter((requestId): requestId is string => !!requestId)\n  }\n\n  if (!uniqueRequestIds.length) {\n    throw new HTTPError(\"Agent log details not ready\", 404)\n  }\n\n  const db = context.getWorkspaceDB()\n  const trigger = determineTrigger(input.sessionId)\n  const isPreview = isPreviewSession(input.sessionId)\n  const firstInput = truncateText(input.firstInput || \"\")\n  const fallbackStartTime = parseDateOrThrow(input.startedAt, \"startedAt\")\n  const fallbackEndTime = parseDateOrThrow(input.completedAt, \"completedAt\")\n\n  const summaryResults = await Promise.all(\n    uniqueRequestIds.map(async requestId => {\n      try {\n        const requestDetail = await fetchLiteLLMRequestSummaryById(\n          requestId,\n          fallbackStartTime,\n          fallbackEndTime\n        )\n        if (!requestDetail) {","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/ai/agentLogs/indexQueue.ts#L90-L126","documentation":"addSessionLog builds an indexed agent-log session record from LiteLLM request data. It first collects distinct request_ids for the session; if none are found (no matching LiteLLM requests yet), it throws an HTTPError 404 'Agent log details not ready' because the details needed to index the session do not exist.","triggerScenarios":"Calling addSessionLog (during agent log queue init/processing) for a sessionId whose LiteLLM requests have not been recorded yet - empty or unflushed LiteLLM logs, or a sessionId mismatch with LiteLLM request metadata.","commonSituations":"Querying agent logs immediately after an agent run before LiteLLM persisted its request rows; a stale sessionId from a failed/aborted run; clock/log-ingestion lag between the agent run and LiteLLM storage.","solutions":["Retry after a short delay so LiteLLM has time to persist the request records.","Verify the sessionId used matches the one passed to LiteLLM during the agent run.","Check LITELLM_URL / LITELLM_MASTER_KEY config so the query is hitting the right LiteLLM instance with data.","If the session genuinely never ran, discard the queued log entry rather than retrying."],"exampleFix":"// before\nawait addSessionLog({ sessionId: input.sessionId, ... })\n// after\nif (!(await sessionHasRequests(input.sessionId))) return // skip not-ready sessions\nawait addSessionLog({ sessionId: input.sessionId, ... })","handlingStrategy":"retry","validationCode":"const requestIds = await fetchLiteLLMRequestIds(sessionId)\nif (!requestIds.length) return // not ready yet; skip instead of throwing","typeGuard":"const hasRequests = (ids: (string | undefined)[]): ids is string[] => ids.length > 0","tryCatchPattern":"try {\n  await addSessionLog(input)\n} catch (e) {\n  if (e instanceof HTTPError && e.status === 404) {\n    await requeueWithDelay(input) // LiteLLM details may arrive later\n  } else {\n    throw e\n  }\n}","preventionTips":["Delay log indexing until after LiteLLM has persisted requests","Verify sessionId consistency between agent runs and LiteLLM metadata","Check LITELLM_URL/LITELLM_MASTER_KEY point at the populated instance","Treat 404 here as transient and requeue with backoff"],"tags":["ai","logging","http-404"],"backgroundTag":"log-details-not-ready","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}