{"record":{"id":"1ee1c30d6bb125a8","repo":"KeygraphHQ/shannon","slug":"prompt-file-not-found-promptpath","errorCode":null,"errorMessage":"Prompt file not found: ${promptPath}","messagePattern":"Prompt file not found: (.+?)","errorType":"exception","errorClass":"PentestError","httpStatus":null,"severity":"error","filePath":"apps/worker/src/services/prompt-manager.ts","lineNumber":473,"sourceCode":"export async function loadPrompt(\n  promptName: string,\n  variables: PromptVariables,\n  config: DistributedConfig | null = null,\n  pipelineTestingMode: boolean = false,\n  logger: ActivityLogger,\n  promptDir?: string,\n): Promise<string> {\n  try {\n    const basePromptsDir = resolvePromptDir(promptDir);\n    const promptsDir = pipelineTestingMode ? path.join(basePromptsDir, 'pipeline-testing') : basePromptsDir;\n    const promptPath = path.join(promptsDir, `${promptName}.txt`);\n\n    if (pipelineTestingMode) {\n      logger.info(`Using pipeline testing prompt: ${promptPath}`);\n    }\n\n    if (!(await fs.pathExists(promptPath))) {\n      throw new PentestError(`Prompt file not found: ${promptPath}`, 'prompt', false, { promptName, promptPath });\n    }\n\n    // 2. Assign Playwright session based on agent name\n    const enhancedVariables: PromptVariables = { ...variables };\n\n    const session = PLAYWRIGHT_SESSION_MAPPING[promptName as keyof typeof PLAYWRIGHT_SESSION_MAPPING];\n    if (session) {\n      enhancedVariables.PLAYWRIGHT_SESSION = session;\n      logger.info(`Assigned ${promptName} -> ${enhancedVariables.PLAYWRIGHT_SESSION}`);\n    } else {\n      enhancedVariables.PLAYWRIGHT_SESSION = 'agent1';\n      logger.warn(`Unknown agent ${promptName}, using fallback -> ${enhancedVariables.PLAYWRIGHT_SESSION}`);\n    }\n\n    // 3. Read template file\n    let template = await fs.readFile(promptPath, 'utf8');\n\n    // 4. Process @include directives","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/KeygraphHQ/shannon/blob/1ae0a142f8525410a688f0309fd003cc5b1d92de/apps/worker/src/services/prompt-manager.ts#L455-L491","documentation":"Thrown by loadPrompt when the prompt template file at <promptsDir>/<promptName>.txt does not exist (fs.pathExists returns false). promptsDir is resolvePromptDir(promptDir), optionally suffixed with /pipeline-testing when pipeline-testing mode is on. Category 'prompt', non-retryable. Triggered by an unknown agent name, a wrong promptDir override, or pipeline-testing mode pointing at a subdir lacking the file.","triggerScenarios":"loadPrompt is called with a promptName that has no corresponding .txt in the resolved prompts directory; pipeline-testing mode is enabled (--pipeline-testing) but apps/worker/prompts/pipeline-testing/<name>.txt is absent; a promptDir override (relative to SHANNON_WORKER_ROOT or absolute) does not contain the named prompt; an agent was added to the registry (AGENTS) but its prompt template was not created.","commonSituations":"Adding a new agent per the dev guide but forgetting step 2 (create apps/worker/prompts/<name>.txt). Running --pipeline-testing against an image built before the pipeline-testing prompts existed. A custom Docker image that excluded some prompt files. Typo in the agent/prompt name.","solutions":["Check context.promptPath on the thrown PentestError for the exact missing file, then confirm it exists in the container/filesystem.","If it is a pipeline-testing run, ensure apps/worker/prompts/pipeline-testing/<name>.txt exists, or drop --pipeline-testing to use the standard prompt.","If you added a new agent, create the prompt template under apps/worker/prompts/ (and pipeline-testing/ if used) and rebuild the image.","If using promptDir override, confirm it resolves (resolvePromptDir) to a tree containing <name>.txt.","Rebuild the local image (./shannon build) or pull the latest npx image so prompts are in sync with the worker code."],"exampleFix":"// before: new agent 'vuln-graphql' registered but no prompt file\n//   loadPrompt('vuln-graphql', vars, ...)  -> 'Prompt file not found: .../vuln-graphql.txt'\n// after: create the template\n//   touch apps/worker/prompts/vuln-graphql.txt  (then author content)\n//   ./shannon build","handlingStrategy":"validation","validationCode":"// Confirm the prompt file exists for the resolved prompts dir before the workflow runs\nimport { pathExists } from 'fs-extra';\nconst promptsDir = pipelineTesting ? path.join(PROMPTS_DIR, 'pipeline-testing') : PROMPTS_DIR;\nconst promptPath = path.join(promptsDir, `${agentName}.txt`);\nif (!(await pathExists(promptPath))) {\n  throw new Error(`Missing prompt template for agent '${agentName}': ${promptPath}`);\n}","typeGuard":"function isKnownAgent(name: string): name is AgentName {\n  return name in AGENTS;\n}","tryCatchPattern":"try {\n  await loadPrompt(agentName, vars, config, pipelineTesting, logger, promptDir);\n} catch (e) {\n  if (e instanceof PentestError && /Prompt file not found/.test(e.message)) {\n    // either disable pipeline-testing mode, or create/restore the template then rebuild\n    const path = (e.context as any)?.promptPath;\n    throw new Error(`Restore missing prompt: ${path}`);\n  }\n  throw e;\n}","preventionTips":["When adding an agent to AGENTS, always create its prompt template in the same commit.","Keep apps/worker/prompts/ and apps/worker/prompts/pipeline-testing/ in sync.","Rebuild the worker image after adding prompts; npx users should pull the latest image.","Add a CI check that every key in AGENTS has a corresponding .txt in both prompt dirs."],"tags":["prompt","filesystem","config","agent","pipeline-testing"],"backgroundTag":null,"analyzedSha":"1ae0a142f8525410a688f0309fd003cc5b1d92de","analyzedAt":"2026-08-12T17:40:03.583Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}