{"record":{"id":"4e64f259141e70a1","repo":"paperclipai/paperclip","slug":"failed-to-seed-ceo-instructions","errorCode":null,"errorMessage":"Failed to seed CEO instructions:","messagePattern":"Failed to seed CEO instructions:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ui/src/components/OnboardingWizard.tsx","lineNumber":1212,"sourceCode":"        const bundle = await agentsApi.instructionsBundle(agent.id, createdCompanyId);\n        await agentsApi.saveInstructionsFile(\n          agent.id,\n          {\n            path: bundle.entryFile,\n            content: composeCeoInstructions({\n              companyName,\n              companyGoal,\n              growPath: onboardingPath === \"grow\",\n              growWorkflows,\n              growPainPoints,\n              growAutomate,\n              q1, q2, q3, q4,\n            }),\n          },\n          createdCompanyId,\n        );\n      } catch (err) {\n        console.warn(\"Failed to seed CEO instructions:\", err);\n      }\n\n      if (!stillTheSameCompany(createdCompanyId)) return;\n      setCreatedAgentId(agent.id);\n      // Advance to the Review step — the lead is now online. The user drives\n      // strategy + hiring from the planning chat after \"Get started\".\n      setStep(5);\n    } catch (err) {\n      setError(err instanceof Error ? err.message : \"Failed to create agent\");\n    } finally {\n      setLoading(false);\n    }\n  }\n\n  async function handleUnsetAnthropicApiKey() {\n    if (!createdCompanyId || unsetAnthropicLoading) return;\n    setUnsetAnthropicLoading(true);\n    setError(null);","sourceCodeStart":1194,"sourceCodeEnd":1230,"githubUrl":"https://github.com/paperclipai/paperclip/blob/a7e689b3c35347b529cb9f54c9b9a8575a3dcab6/ui/src/components/OnboardingWizard.tsx#L1194-L1230","documentation":"Logged from the OnboardingWizard's first-agent setup: after agentsApi.hire() and approval succeed, the wizard fetches the CEO instructions bundle (agentsApi.instructionsBundle) and saves a seeded instructions file (agentsApi.saveInstructionsFile). If either API call rejects, the catch logs this warning and deliberately continues to step 5 — per the in-code comment, the failure is non-fatal because the hired agent can still run with adapter defaults.","triggerScenarios":"Running the onboarding wizard, completing agent hire, then the GET instructions-bundle or POST save-instructions-file request failing: API server restart mid-wizard, 401 from an expired session, 404 for a just-deleted agent/company, or a 5xx when the server cannot write the instructions file to the workspace.","commonSituations":"Dev server restarted while the wizard was open; auth token expired during a long wizard session; company context switched (stillTheSameCompany race); server-side filesystem/permission error writing the agent instructions file.","solutions":["Open browser devtools Network tab, find the failing /api/.../agents/{id}/instructions request and read the HTTP status — that is the real error (the warn only wraps it).","Confirm the API is reachable: curl http://localhost:3100/api/health.","If 401/403: log in again and restart onboarding.","If the agent was created despite the warning: seed the CEO instructions manually from the agent's instructions page in the board UI.","Check server logs for the 5xx root cause (workspace path, permissions) if the status is 500."],"exampleFix":"// before\ntry {\n  const bundle = await agentsApi.instructionsBundle(agent.id, createdCompanyId);\n  await agentsApi.saveInstructionsFile(agent.id, { path: bundle.entryFile, content }, createdCompanyId);\n} catch (err) {\n  console.warn(\"Failed to seed CEO instructions:\", err);\n}\n\n// after — same non-fatal contract, but the user is told instead of only the console\ntry {\n  const bundle = await agentsApi.instructionsBundle(agent.id, createdCompanyId);\n  await agentsApi.saveInstructionsFile(agent.id, { path: bundle.entryFile, content }, createdCompanyId);\n} catch (err) {\n  console.warn(\"Failed to seed CEO instructions:\", err);\n  setSeedInstructionsNotice(\"Agent created, but its instruction file could not be seeded. Edit it from the agent page.\");\n}","handlingStrategy":"try-catch","validationCode":"const health = await fetch(`${apiBase}/api/health`);\nif (!health.ok) throw new Error(`API unreachable (${health.status}) — fix connectivity before onboarding`);","typeGuard":"const isApiError = (e: unknown): e is { status?: number; message: string } =>\n  typeof e === \"object\" && e !== null && \"message\" in e;","tryCatchPattern":"try {\n  const bundle = await agentsApi.instructionsBundle(agent.id, companyId);\n  await agentsApi.saveInstructionsFile(agent.id, { path: bundle.entryFile, content }, companyId);\n} catch (err) {\n  // Non-fatal by design: the agent exists. Log, optionally notify, continue the wizard.\n  console.warn(\"Failed to seed CEO instructions:\", err instanceof Error ? err.message : err);\n}","preventionTips":["Keep the API server running and the auth session fresh for the whole wizard (it makes several sequential calls after hire).","Treat this warn as 'agent created, instructions missing' — verify the instructions file from the agent page after onboarding.","Watch the Network tab during onboarding; the wrapped error's HTTP status is the actionable part.","In e2e tests, assert on the instructions API directly so this path is covered."],"tags":["ui","onboarding","api","agent-instructions","non-fatal"],"backgroundTag":"http-request-failed","analyzedSha":"a7e689b3c35347b529cb9f54c9b9a8575a3dcab6","analyzedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}