fix(ai): name the field a nullable section's submission got wrong - #1002
Merged
Merged
Conversation
An answer section typed object-or-null that failed its schema was reported as "does not match any schema of [...]", with the whole value and both branches echoed back. The model never learned which field was wrong. In a production run of 108k filings, 15 of 26 answer-budget failures were one model resubmitting the same extra property until its time ran out. When exactly one branch of a failing anyOf/oneOf takes the value's JSON type, AgentTask now reports that branch's own errors, re-rooted at the value's path: "Additional property `trust_total` in `#/offering_terms/trust_total` is not allowed". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QnfZoVpU6VAoGoTkN3jtmv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
AgentTaskturns a failedsubmit_answervalidation into a correction for the model. For a section typedanyOf: [object, null], json-schema-library reports onlyany-of-error: "Value{…}at#/xdoes not match any schema of[…]". The model can't tell what to fix from that.describeSchemaErrors(inToolCallingUtils) handles failinganyOf/oneOferrors. When exactly one branch accepts the value's JSON type, it validates the value against that branch and reports the branch's own errors, re-rooted at the value's path. All other errors pass through unchanged.Before:
After:
Why
In an embarc-data production run (108k filings read), 23 of 26 S-1 readings that hit their 9-minute budget did so by resubmitting an invalid answer. In 15 of those, the only fault was one extra property in a nullable section. One session submitted 36 times.
Tests
packages/test/src/test/ai/describeSchemaErrors.test.ts.AgentTask.test.ts,AgentTaskTurnControls.test.ts.🤖 Generated with Claude Code
https://claude.ai/code/session_01QnfZoVpU6VAoGoTkN3jtmv