Repository navigation
fix(schema): raise instead of silently dropping invalid local model instances - #204
Merged
frostming merged 1 commit intoNov 25, 2026
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>
raymondfeng
added a commit
to raymondfeng/python-sdk
that referenced
this pull request
Nov 25, 2026
Regenerate the v1 bindings from schema-v1.35.0 (`make gen-all`). Builds on the stateless MCP-over-ACP binding, which 1.33 and later require. - Pass the new session fields to the wire. The signature generator added them to the senders, but the hand-written bodies dropped them: `system_prompt` and `config_options` on new/load/resume/fork, `cursor_id` on fork, `archived` on list. Add a wire test, and a test that every sender uses all its parameters. - Add the methods 1.33 introduces, all unstable: `archive_session`, `unarchive_session`, `session_status`, `session_options`, `set_session_title`, `auth_status`, and the client notification `auth_status_update`. - Remove next edit suggestions and the document notifications, which the schema removed (agent-client-protocol db2116ef, #2266). - Name the 1.33 `PlanUpdateContent` variants by kind. The schema dropped the `file` variant, and the positional name map turned `markdown` into `PlanUpdateFile`. Drop the stale `NesSuggestion` map. - Move two tests off models the schema changed: `ToolCallLocation.line` for the default-on-error salvage, `StringPropertySchema.format` for inline literals. - 1.35 adds the optional `sessionId` and `toolCallId` to `mcp/message`: the sender passes them, and a test sends both. - Since 1.33, `session/new`'s `mcpServers` is no longer `x-deserialize-skip-invalid-items`: a malformed server is a validation error, not skipped. The agentclientprotocol#204 test now says so. - Regenerate experimental v2 at its current pin (alpha.7) with the current generator. BREAKING CHANGE: the NES and document methods are gone (`start_nes`, `suggest_nes`, `close_nes`, `accept_nes`, `reject_nes`, `did_open`, `did_change`, `did_close`, `did_save`, `did_focus`), and so are their models. `PlanUpdateFile` is gone with the schema's `file` plan update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 tasks done
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.)