{"record":{"id":"379d4b53647fb2e3","repo":"can1357/oh-my-pi","slug":"invalid-scope-output-schema-error","errorCode":null,"errorMessage":"Invalid ${scope} output schema: ${error}","messagePattern":"Invalid (.+?) output schema: (.+?)","errorType":"validation","errorClass":"StructuredSubagentError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/task/structured-subagent.ts","lineNumber":279,"sourceCode":"\tconst disabledAgents = request.session.settings.get(\"task.disabledAgents\") as string[];\n\tif (disabledAgents.includes(agentName)) {\n\t\tconst enabled = discovery.agents\n\t\t\t.filter(candidate => !disabledAgents.includes(candidate.name))\n\t\t\t.map(candidate => candidate.name);\n\t\tthrow new StructuredSubagentError(\n\t\t\t\"preflight\",\n\t\t\t`Agent \"${agentName}\" is disabled in settings. Enable it via /agents, or use a different agent type.${enabled.length > 0 ? ` Available: ${enabled.join(\", \")}` : \"\"}`,\n\t\t);\n\t}\n\n\tconst effectiveAgent = planMode ? createPlanModeAgent(agent) : agent;\n\tconst schema = resolveSchema(request, effectiveAgent);\n\tif (schema.source === \"caller\" || (schema.source !== \"none\" && schema.mode === \"strict\")) {\n\t\tconst { error } = buildOutputValidator(schema.schema);\n\t\tif (error) {\n\t\t\tconst scope =\n\t\t\t\tschema.source === \"caller\" ? (schema.mode === \"strict\" ? \"strict caller\" : \"caller\") : \"strict effective\";\n\t\t\tthrow new StructuredSubagentError(\"preflight\", `Invalid ${scope} output schema: ${error}`);\n\t\t}\n\t}\n\tconst agentModelOverrides = request.session.settings.get(\"task.agentModelOverrides\");\n\tconst parentActiveModelPattern = request.session.getActiveModelString?.();\n\tconst modelResolution = {\n\t\trequestModel: request.model,\n\t\tsettingsOverride: agentModelOverrides[agentName],\n\t\tagentModel: effectiveAgent.model,\n\t\tsettings: request.session.settings,\n\t\tactiveModelPattern: parentActiveModelPattern,\n\t\tfallbackModelPattern: request.session.getModelString?.(),\n\t};\n\t// Role identity and patterns come from one call so they cannot be derived\n\t// from different sources: the expansion below discards the alias, and the\n\t// child's inherited retry-fallback chain is keyed off the role.\n\tconst { patterns: modelOverride, role: modelRole } = resolveAgentModelSelection(modelResolution);\n\tconst isolationMode = request.session.settings.get(\"task.isolation.mode\");\n\tconst isIsolated = request.isolation?.requested === true;","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/task/structured-subagent.ts#L261-L297","documentation":"Thrown in preflight when an output schema fails validation at build time. Schemas from the caller (normal or strict mode) or a strict-mode effective-agent schema are compiled by `buildOutputValidator`; a compile error (malformed JSON Schema, unsupported constructs) raises this with the scope (strict caller / caller / strict effective) and the underlying error message.","triggerScenarios":"Passing `outputSchema` in the task request (caller scope) with invalid JSON Schema; an agent-defined schema used in strict mode that `buildOutputValidator` cannot compile.","commonSituations":"Handwritten schemas with typos (bad `type` values, dangling $ref); schemas copied from a different validator dialect (e.g. zod-to-JSON drift); strict mode enabled on an agent whose schema uses unsupported keywords.","solutions":["Fix the schema according to the error message from buildOutputValidator","Validate the JSON Schema with a standalone schema validator before passing it","Drop strict mode or remove the agent-level schema if only the effective strict schema is invalid"],"exampleFix":"// before\nawait task({ agent: \"a\", outputSchema: { type: \"stirng\" } });\n// after\nawait task({ agent: \"a\", outputSchema: { type: \"string\" } });","handlingStrategy":"validation","validationCode":"const { error } = buildOutputValidator(myOutputSchema);\nif (error) throw new Error(`Invalid output schema: ${error}`);\nawait task({ agent, outputSchema: myOutputSchema });","typeGuard":null,"tryCatchPattern":"try {\n  await task(req);\n} catch (e) {\n  if (e instanceof StructuredSubagentError && e.message.includes(\"output schema\")) {\n    return task({ ...req, outputSchema: undefined }); // degrade to unstructured\n  }\n  throw e;\n}","preventionTips":["Validate schemas with buildOutputValidator (or a JSON Schema validator) in tests","Stick to the schema dialect buildOutputValidator supports; avoid exotic keywords","Pin strict-mode agent schemas to reviewed, tested definitions"],"tags":["subagent","json-schema","validation","preflight"],"backgroundTag":"schema-validation-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}