feat: enhance output validator with error handling and schema support#5
Conversation
Z-M-Huang
left a comment
There was a problem hiding this comment.
GitVibe Review Matrix
Status: completed
Next state: changes-required
Synthesized 3 successful role reviews for PR #5 and performed an additional diff inspection. One regression needs a fix before approval: discriminator auto-enabling can turn previously valid schemas into invalid configured schemas.
Next Action
Continue with changes-required.
Result
When present, required fixes are posted as pull request review comments. Full structured output remains in the workflow run summary.
Workflow run: https://github.com/markhuangai/agentool/actions/runs/26477105606
Inline comments: 1
Required Fixes
- src/output-validator/index.ts:192 unconditionally adds
discriminator: truewheneverhasOneOfDiscriminator(config.schema)is true. Ajv documents that discriminator mode is not enabled by default and that compile fails when its limitations are not met, including unsupportedmapping, missing required discriminator property, non-inline/non-direct-$ref branches, or non-unique const/enum tag values. Because the pre-PR Ajv config usedstrict: falsewithout discriminator mode, those schemas could compile and validate through normaloneOf; this PR can now returnError [output-validator]: Invalid configured schemafor every call. Fix by only enabling discriminator mode for schemas that satisfy Ajv's discriminator constraints, or by retrying compilation without discriminator mode when discriminator compilation fails.
| const ajv = new Ajv({ | ||
| allErrors: true, | ||
| strict: false, | ||
| ...(hasOneOfDiscriminator(config.schema) ? { discriminator: true } : {}), |
There was a problem hiding this comment.
This enables Ajv discriminator mode for any schema that merely has discriminator.propertyName next to oneOf. Ajv discriminator mode has additional compile-time constraints, so schemas that previously compiled with normal oneOf validation can now become invalid configured schemas. Please add compatibility checks or fall back to a non-discriminator compile when discriminator compilation fails.
… and explicit configuration error handling
Z-M-Huang
left a comment
There was a problem hiding this comment.
GitVibe Review Matrix
Status: completed
Next state: review-passed
Synthesized 3/3 successful role reviews for PR #5 and re-inspected the follow-up diff. The prior discriminator auto-enable regression is addressed by a fallback compile path, and no blocking correctness, security, regression, test, or maintainability issues remain.
Next Action
Continue with review-passed.
Result
When present, required fixes are posted as pull request review comments. Full structured output remains in the workflow run summary.
Workflow run: https://github.com/markhuangai/agentool/actions/runs/26480711312
No description provided.