Skip to content

fix(schema): raise instead of silently dropping invalid local model instances - #204

Merged
frostming merged 1 commit into
agentclientprotocol:mainfrom
sammyawad:fix/skip-invalid-items-local-models
Nov 25, 2026
Merged

frostming merged 1 commit into
agentclientprotocol:mainfrom
sammyawad:fix/skip-invalid-items-local-models

Conversation

@sammyawad

Copy link
Copy Markdown
Contributor

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(...)]) became mcpServers: [] with no error, so the agent started without its MCP server.

Now an item that is already a BaseModel instance re-raises its ValidationError. Dicts from the wire keep today's lenient behaviour. One extra line in src/acp/_deserialize.py, plus tests.

Side note found while testing: the same fields as an incoming dict (no type) parse fine as HttpMcpServer, because type defaults to "http". Only the McpServerHttp instance 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: McpServerHttp raises, HttpMcpServer works, incoming JSON unchanged (malformed entry still skipped).
  • Full pytest: 554 passed, 2 skipped. 2 failures in tests/real_user/test_stdio_limits.py also fail on main on this machine (Windows 11, Python 3.12), so they are not from this change.
  • ruff check and ruff format --check clean on the changed files. I did not run make check (no uv/make on this machine), so ty and deptry were not run.

Docs & screenshots

None needed: no public API change; the docstring of skip_invalid_items now says which items are skipped and which raise.

Checklist

  • Conventional Commit title (e.g. feat:, fix:).
  • Tests cover the change or are not required (explain above).
  • Docs/examples updated when behaviour is user-facing.
  • Schema regenerations (make gen-all) are called out if applicable. (None: _deserialize.py is hand-written.)

…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>

@frostming frostming left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@frostming
frostming merged commit 679be93 into agentclientprotocol:main Nov 25, 2026
9 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NewSessionRequest silently drops McpServerHttp items (no error)

2 participants