Repository navigation
fix(agent): store parsed values and enforce object refinements in context setters - #161
Open
alexb-openrouter wants to merge 1 commit into
Open
alexb-openrouter wants to merge 1 commit into
alexb-openrouter wants to merge 1 commit into
Conversation
…text setters Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
This branch has not been deployed
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.
Summary
Risk fixed:
ctx.setContext()/ctx.setSharedContext()calledz4.parse(fieldSchema, value)for each field but stored the raw input. Field transforms, defaults and coercions declared incontextSchema/sharedContextSchemawere never applied to what later tools read. For example, withlevel: z.number().transform(n => Math.min(n, 0)), a tool could storelevel: 1, and the next tool would see1. Object-level.refine()checks were also not run when writing. They were only enforced later, when the next tool's context was built.Change in
validatePartialAgainstSchema(tool-context.ts):buildToolExecuteContextalready enforces when it validates stored context eagerly, so the error now happens at the write instead of at the next tool call.Tests: new cases in
shared-context.test.tscover the transform forsetSharedContextandsetContext, and an object-level refinement that rejects a write and then accepts it once the other field allows it. All three fail onmainand pass with this change. Full unit suite, biome and typecheck pass.Note: open PR #107 (Standard Schema support) rewrites this same function and keeps the old raw-value behavior on its Zod path. Whichever PR merges second needs a rebase, and that rebase should keep the parsed-output and whole-object checks.