Skip to content

fix(ws): ignore non-object JSON frames in client transport - #169

Open
CHLIN0 wants to merge 1 commit into
agentclientprotocol:mainfrom
CHLIN0:codex/ws-ignore-non-object-frames
Open

CHLIN0 wants to merge 1 commit into
agentclientprotocol:mainfrom
CHLIN0:codex/ws-ignore-non-object-frames

Conversation

@CHLIN0

@CHLIN0 CHLIN0 commented Oct 16, 2026

Copy link
Copy Markdown

Summary

When a WebSocket peer sends null before a valid JSON-RPC response, the client treats it as EOF and rejects the pending request. Other non-object JSON values (for example []) reach Connection._process_message() and fail on .get(), also dropping the valid response behind them.

Return only decoded dictionaries from the WebSocket client transport, matching the existing WebSocket server and the stdio recovery behavior accepted in #153. Invalid JSON and binary frames remain ignored; a real socket close still returns None. This does not add batch support or change JSON-RPC error responses. The transport docs now describe the recovery behavior.

Related issues

Follow-up to #153, whose scope note explicitly left the WebSocket client path unchanged pending a live WebSocket reproduction. #166 covers server binary-frame warnings; #167 covers response IDs and remains separate.

Testing

  • New regression cases against unchanged production code: 9 failed, 2 passed (invalid JSON and binary controls).
  • With the fix, WebSocket, cookie and connection-recovery tests: 29 passed.
  • Tests use a loopback WebSocket server and the production create_websocket_stream() transport. Connection tests send an initialize request and verify that its response survives both null and [] preceding it. Transport tests cover arrays, strings, numbers, booleans, nested null/array values in an otherwise valid object, invalid JSON, binary frames and actual close.
  • make check: passed (lockfile, pre-commit, Ruff, ty, deptry).
  • ACP_ENABLE_GEMINI_TESTS=0 make test: 419 passed, 1 skipped.
  • Separate native Codex review: no actionable findings; additional live-socket cancellation/EOF probe passed.
  • git diff --check: passed; final patch hash matches the reviewed patch.

No model/provider calls or Gemini integration tests were enabled. Local validation is on macOS with Python 3.13.9; the upstream multi-Python CI matrix has not run locally.

Docs & screenshots

Updated docs/web-transport.md; no API or schema generation changes.

Checklist

  • Conventional Commit title.
  • Tests cover the change, including red-before/green-after reproduction.
  • Transport docs updated.
  • No schema regeneration required.

AI-assisted development with OpenAI Codex, including a separate native Codex reviewer.

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.

2 participants