Skip to content

test: reproduce websocket client echo bug#6

Closed
kamikaz1k wants to merge 1 commit into
agentclientprotocol:mainfrom
kamikaz1k:codex/repro-client-transport-echo-bug
Closed

test: reproduce websocket client echo bug#6
kamikaz1k wants to merge 1 commit into
agentclientprotocol:mainfrom
kamikaz1k:codex/repro-client-transport-echo-bug

Conversation

@kamikaz1k
Copy link
Copy Markdown

@kamikaz1k kamikaz1k commented May 23, 2026

This is a reproduction of an issue I found while working on the HTTP SSE Client. I can do the follow up work to fix this, but wanted to make sure I understood the intention behind this as I expect there are in the wild consumers of this SDK and might be affected by any changes.

This behaviour seems to be Java SDK implementation specific.

The issue is: client handles request correctly AND accidentally emits the original request back through the transport handler.

The root cause is:

this.transport.connect(mono -> mono.doOnNext(this::handle))

doOnNext(...) performs a side effect, but it does not replace the message. It passes the original inbound request downstream unchanged.

and so the fix would be to

mono.doOnNext(this::handle).then(Mono.empty())

markpollack pushed a commit that referenced this pull request May 26, 2026
AcpClientSession wired the transport with doOnNext(this::handle),
which performs the side effect but passes the original message
through downstream. The WebSocket transport then sent it back over
the wire, causing the agent to receive its own requests as inbound
client messages.

Fix: consume the message after handling with .then(Mono.empty())
so nothing passes through to the transport's outbound path.

Test reproduction by Kaiser Dandangi (@kamikaz1k) via PR #6.
@markpollack
Copy link
Copy Markdown
Contributor

Good catch. The root cause analysis is correct — doOnNext preserves the message downstream and the WebSocket transport sends it back.

Applied your test and the fix (mono.doOnNext(this::handle).then(Mono.empty())) in 9a1ac23. Credited in the commit message.

Thanks for the clean reproduction — the test isolates the bug path well.

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