Repository navigation
fix(agent): enforce JSON Schema dict validation and forward validated HITL outputs - #45
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
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
Fixes two schema-enforcement gaps in tool input and HITL output handling:
dictvalidation (src/openrouter_agent/_utils.py):validate_schemapreviously fell through and returnedvalueunvalidated wheneverschemawas a plain JSON Schemadict, allowing model-supplied arguments that violate the advertised schema to execute. Plaindictschemas are now sanitized and validated withjsonschema(validator_for(cleaned)+check_schema+validate) before tool execution and approval predicate evaluation.output_schemaforwarding (src/openrouter_agent/tool_executor.py): Inapply_on_response_received_hooks, when noon_response_receivedhook was configured,validate_schema(output_schema, raw)ran but discarded its return value and appendedoriginalunchanged, forwarding extra fields that Pydantic or a custom validator stripped. The validated output is now serialized (validated if is_content_array(validated) else json_dumps(validated)) and written back to the item'soutputwhile preserving the rest of the item shape.Testing
tests/unit/test_schema_enforcement.pycovering JSON Schemadictvalidation (regular, generator, HITL tools, approval predicates, malformed schemas, andcall_modelturns) and HITLoutput_schemastripping/forwarding with and withouton_response_receivedhooks../.upstreamer/scripts/verify.sh(uv sync,uv lock --check,ruff check,ruff format --check,mypy src tests,pytest tests/unit --cov --cov-fail-under=83).