Skip to content
1 min read · 191 words

batteries/orchestration/reason

Functions

FunctionDescription
decodeOutputSchemaDecode a ReasonNodeDefinition.outputSchema — which is stored as an ENCODED STRING, not a live Schema. A live validation schema is not Encodable — encoding one throws E_UNENCODABLE_VALUE: Value of type symbol (Symbol(override)) is not encodable, which would make the whole plan unpersistable. This has been verified against the real packages. Tool solves the same problem the same way at src/lib/classes/tool.ts:449-490.
joinPromptPartsJoin prompt parts in order, substituting each reference's resolved value. A reference that resolves to undefined renders as the explicit absent marker '[unresolved: <nodeId>]', naming the node whose output was missing.
stripInstructionTagsRemove <instruction> and </instruction> tags from author-supplied prompt text. Case-insensitive, tolerant of whitespace inside the tag. Only those two tags are removed.
validateReasonerOutputValidate captured tool arguments against the decoded schema, returning a discriminated result rather than throwing.
wrapInstructionWrap the authoritative instruction in <instruction> tags and place the stripped context after it, with a line telling the model to ignore any instructions appearing inside the context payload.