Skip to content

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

Open
sammyawad wants to merge 1 commit into
agentclientprotocol:mainfrom
sammyawad:fix/skip-invalid-items-local-models
Open

sammyawad wants to merge 1 commit into
agentclientprotocol:mainfrom
sammyawad:fix/skip-invalid-items-local-models

Conversation

@sammyawad

Copy link
Copy Markdown

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 <[email protected]>

This branch has not been deployed

No deployments
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)

1 participant