Repository navigation
fix(agent): validate tool context against its schema before storing it - #44
Open
alexb-openrouter wants to merge 2 commits into
Open
alexb-openrouter wants to merge 2 commits into
alexb-openrouter wants to merge 2 commits into
Conversation
Contributor
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
alexb-openrouter
marked this pull request as ready for review
November 30, 2026 16:48
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
set_context/set_shared_contextonly dropped keys not in the schema; values were never validated. A tool could store{"capability": "admin"}under a schema declaringLiteral["read"], and the next tool sharing the sameToolContextStoreread it. Initial context was never validated either, andextract_tool_contextwas unused.This matches
@openrouter/agent'stool-context.ts:model_dump()output, so validators, coercions and defaults apply.build_tool_execute_contextnow callsextract_tool_context(store, key, schema)(new signature, internal and not exported) to validate the tool's stored context and the shared context when a schema is set. Invalid initial context raises before the tool body runs.execute_toolreturns it as the call'serror.Tests in
tests/unit/test_tool_context_validation.py:Literalrejection across twoexecute_toolcalls sharing one store (local and shared), store and subscribers unchanged on failure, validators/coercion/defaults applied, merge with existing values, and initial-context rejection. 6 of 7 fail on main.