Skip to content

fix(proxy): tell a request the server started from a result - #130

Merged
moise10r merged 2 commits into
Memnox:mainfrom
Cedric921:fix/tell-a-server-request-from-a-result
Oct 12, 2026
Merged

moise10r merged 2 commits into
Memnox:mainfrom
Cedric921:fix/tell-a-server-request-from-a-result

Conversation

@Cedric921

Copy link
Copy Markdown
Contributor

Closes #7.

What this changes

replyFor looked an incoming server message up in listRequestIds and openCalls by id alone. Client and server number their ids independently, so a request the server starts can carry the id of a call the client has open. On main, with tools/call id 1 open, {"id":1,"method":"sampling/createMessage"} arriving from the server:

  • retires the open call and writes a ledger row with an empty result
  • runs the server's own request through frameResult and withNotes, so it reaches the client rewritten
  • lets the real result through afterwards, unrecorded and unframed
  • and where the id belonged to an open tools/list, fires onListing([]) and wipes the manifest

One condition fixes it: a server message counts as a response only when it has no method and does carry a result or an error. Anything the server started — request or notification — goes to the client untouched.

How it was verified

Seven tests, all of which fail on main:

  • sampling/createMessage, roots/list, elicitation/create and ping each reach the client with their method intact, and no row is written for a call that has not come back
  • the real result that follows is still recorded and still framed — the test puts instruction-shaped text in it and asserts the quotation marker, so the collision cannot silently cost the framing
  • an open tools/list keeps its manifest when a roots/list steals its id, and still reads the listing when the real response arrives
  • a server notification, which carries no id at all, passes through
Test Files  286 passed (286)
     Tests  8460 passed (8460)

prettier, tsc, vitest and knip all clean, on Node 24.

Checklist

  • pnpm format && pnpm typecheck && pnpm test && pnpm deadcode all pass
  • Behaviour change ships with a test
  • No any, no magic values, no console.* outside cli-output.ts
  • If this touches the decision path: still deterministic — one shape check on a message, no model, network or randomness
  • If this changes a verb table: n/a
  • If this changes a command, flag or file it writes: n/a; the ledger stops gaining rows for calls that have not returned, which the changeset names

@Cedric921
Cedric921 requested a review from moise10r as a code owner October 6, 2026 14:52
@moise10r
moise10r merged commit f77eee9 into Memnox:main Oct 12, 2026
11 checks passed
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.

proxy: a request the server starts is mistaken for a tool result when the ids collide

2 participants