Skip to content

fix(server): send gRPC proxy requests to the session that owns them - #736

Open
omkargaikwad23 wants to merge 6 commits into
mainfrom
fix/grpc-proxy-session-queues
Open

omkargaikwad23 wants to merge 6 commits into
mainfrom
fix/grpc-proxy-session-queues

Conversation

@omkargaikwad23

@omkargaikwad23 omkargaikwad23 commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

What

GrpcProxyModel sends each request to the queues of its own session.

  • The model uses its session ID. The Interact handler puts the session ID into the config, and the Cortado evaluator gives that config to the model.
  • A model with no session ID uses the RPC ID of the caller.
  • If no active session has that ID, the request fails with RuntimeError. There is no fallback to a different session.

Why

The model sent each request to the first active session. With two Interact sessions at the same time, the prompts of the second session went to the client of the first session. The second session then got the answers of that client.

Behavior change: a grpc_proxy model with no session ID and no RPC ID now fails. Before, it used the first active session. This applies to a model that get_generator builds in the oneshot, interact, and dataagent orchestrators, because their worker threads do not have the RPC ID. The Cortado evaluator is not affected.

Testing

  • grpc_proxy_session_test.py: 5 tests pass. With 9 related test files: 158 tests pass. pycodestyle is clean.
  • A script with two sessions, A and B. Each session has a client thread that answers with its own name. Session B sends a request.
Case main This PR
A and B are active, model of session B Answer from the client of A Answer from the client of B
B disconnected, A is active, model of session B Answer from the client of A RuntimeError
B disconnected, A is active, model with no session ID and the RPC ID of B Answer from the client of A RuntimeError
  • Real run with Gemini CLI 0.25.1 and 2 scenarios that use no tools: both pass. This run is a regression check. It does not use the changed code.
  • Not run: two real Interact streams through the eval server.

Logs (Google-internal): https://paste.googleplex.com/6755399437647068

@omkargaikwad23

omkargaikwad23 commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator Author

Verification

I ran the same script on main (6ca77dc) and on this branch. Two sessions, a and b, are active. Each session has a client thread that answers with its own name. Then each session sends one prompt.

Observation main This PR
Session a gets the answer from Client of a Client of a
Session b gets the answer from Client of a Client of b
Prompts that the client of a received Prompt of a, prompt of b Prompt of a
Prompts that the client of b received None Prompt of b

Local tests:

  • grpc_proxy_session_test.py, agent_grpc_proxy_test.py, and evalproto_packaging_test.py: 20 passed.
  • pytest evalbench/test with SKIP_CLOUD_TESTS=true: 1300 passed, 11 skipped.

@omkargaikwad23
omkargaikwad23 marked this pull request as ready for review November 30, 2026 06:05
omkargaikwad23 and others added 2 commits November 30, 2026 06:14
_session_queues checked for a session key and then read it in a second
step. A session can end in a different thread between the two steps, and
the caller then got a KeyError. Each decision now reads PROXY_QUEUES one
time, so the caller gets the "session is not active" error.
f"The proxy session {self.session_id!r} is not active.")
return queues
queues = PROXY_QUEUES.get(rpc_id_var.get())
if queues is not None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This fallback still sends prompts to another session. A model has no session_id when it is built through get_generator (oneshot, interact, dataagent orchestrators), and Interact only checks the generator, not the orchestrator.

Checked the method with two sessions A and B and a model without session_id:

  • both live, caller B: gets B's queues
  • B disconnects (_cleanup_on_drop pops B, its worker threads keep running), caller B: gets A's queues
  • same with session_id=B: RuntimeError, which is what we want

So after B drops, B's remaining prompts go to A's client. If both run the same dataset the conversation IDs collide too, and B's thread replaces A's inbox for that ID.

Lets remove the single session fallback and raise. test_model_without_identity_uses_the_only_session then changes to expect the error.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, I could reproduce it: after B drops, a model without a session ID got A's queues. Fixed in 84f50dd, the single-session fallback is gone and it raises now. One side effect: grpc_proxy with the oneshot, interact, or dataagent orchestrator now fails, because the model has no session ID or RPC ID there. Cortado is not affected.

omkargaikwad23 and others added 2 commits December 2, 2026 20:38
A model with no session ID used the only active session. After its own
session ended, that was the session of another client.

Now the model uses its session ID, or the RPC ID of the caller. If no
active session has that ID, the request fails.
@omkargaikwad23

Copy link
Copy Markdown
Collaborator Author

/gcbrun

1 similar comment
@omkargaikwad23

Copy link
Copy Markdown
Collaborator Author

/gcbrun

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