Skip to content

Commit e3fe03b

Browse files
khaliqgantclaude
andcommitted
fix(schema): support legacy string[] alternatives for backwards compat
Update DecisionSchema to accept both string[] (legacy format) and Alternative[] (new format) for backwards compatibility with existing trajectories. Also add missing confidence field to DecisionSchema. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3455107 commit e3fe03b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/core/schema.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,18 @@ export const AlternativeSchema = z.object({
102102

103103
/**
104104
* Decision schema
105+
* Note: alternatives supports both string[] (legacy) and Alternative[] (new)
105106
*/
106107
export const DecisionSchema = z.object({
107108
question: z.string().min(1, "Decision question is required"),
108109
chosen: z.string().min(1, "Chosen option is required"),
109-
alternatives: z.array(AlternativeSchema),
110+
alternatives: z.array(z.union([z.string(), AlternativeSchema])),
110111
reasoning: z.string().min(1, "Decision reasoning is required"),
112+
confidence: z
113+
.number()
114+
.min(0, "Confidence must be between 0 and 1")
115+
.max(1, "Confidence must be between 0 and 1")
116+
.optional(),
111117
});
112118

113119
/**

0 commit comments

Comments
 (0)