Repository navigation
Conversation
…nstances skip_invalid_items (x-deserialize-skip-invalid-items, agentclientprotocol#117) drops array items that fail validation. That is right for wire data from a newer peer, but it also dropped model instances built in local code: NewSessionRequest(mcp_servers=[McpServerHttp(...)]) became an empty list with no error, so the agent started without its MCP server. An item that is already a BaseModel instance now re-raises its ValidationError. Dicts from the wire keep today's lenient behaviour. Fixes agentclientprotocol#203 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
skip_invalid_items(from #117) drops array items that fail validation. That is right for wire data from a newer peer, but it also dropped model instances built in local code:NewSessionRequest(mcp_servers=[McpServerHttp(...)])becamemcpServers: []with no error, so the agent started without its MCP server.Now an item that is already a
BaseModelinstance re-raises itsValidationError. Dicts from the wire keep today's lenient behaviour. One extra line insrc/acp/_deserialize.py, plus tests.Side note found while testing: the same fields as an incoming dict (no
type) parse fine asHttpMcpServer, becausetypedefaults to"http". Only theMcpServerHttpinstance was being dropped, which made it easy to miss.Related issues
Closes #203
Testing
pytest tests/test_deserialize.py: 7 passed. The 2 new tests fail without the fix (checked by reverting_deserialize.py).test_skip_invalid_items_raises_for_local_model_instances: dicts still skipped, a wrong model instance raises.test_new_session_request_rejects_untagged_mcp_server_instance:McpServerHttpraises,HttpMcpServerworks, incoming JSON unchanged (malformed entry still skipped).pytest: 554 passed, 2 skipped. 2 failures intests/real_user/test_stdio_limits.pyalso fail onmainon this machine (Windows 11, Python 3.12), so they are not from this change.ruff checkandruff format --checkclean on the changed files. I did not runmake check(nouv/makeon this machine), sotyanddeptrywere not run.Docs & screenshots
None needed: no public API change; the docstring of
skip_invalid_itemsnow says which items are skipped and which raise.Checklist
feat:,fix:).make gen-all) are called out if applicable. (None:_deserialize.pyis hand-written.)