Skip to content

[ATOM gRPC] atomesh: chat structured output to ATOM; refuse media and Responses (11/14) - #3668

Closed
Jasen2201 wants to merge 1 commit into
jasen/atom-grpc-10-mesh-session-linkfrom
jasen/atom-grpc-11-mesh-chat-fields
Closed

Jasen2201 wants to merge 1 commit into
jasen/atom-grpc-10-mesh-session-linkfrom
jasen/atom-grpc-11-mesh-chat-fields

Conversation

@Jasen2201

@Jasen2201 Jasen2201 commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Part 11/14 of the stack proposed in #3657. No blocking issues.

Why

A chat sent through atomesh to an ATOM gRPC worker reached ATOM without its structured-output input, so a Kimi-K3 chat that must call a tool decoded without its required channel. A chat carrying an image was served as plain text, since ATOM receives only the rendered token ids.

What changed

  • For a model served by ATOM workers, prepare_chat fills the payload's new StructuredOutput: tools, tool_choice and response_format as sent, and each message's own tools apart. It adds the merged template kwargs the prompt was rendered with (merged_template_kwargs).
  • prompt_opens_reasoning says whether the rendered prompt ends in one of the worker's reasoning markers. SGLang and vLLM requests are unchanged.
  • For a model with an ATOM gRPC worker, the gRPC routers answer 400 unsupported_media to a chat or /generate carrying image, video, audio or embedding input, before preparing it.
  • The regular gRPC router answers 501 unsupported_api to /v1/responses for such a model. SGLang and vLLM workers serve media and Responses as before. mesh_prepare_stage_seconds times the template and encode stages.

Review focus

  1. A model counts as ATOM's when any of its workers is.
  2. The tools ride as sent, not as a named tool_choice narrows them.

Testing

An ATOM chat carries its fields as sent, its kwargs and its reasoning opening; a plain chat carries none, and a chat to an SGLang or vLLM worker none. ATOM workers and an ATOM pair get no media, Responses or Messages request; SGLang and vLLM keep serving them.

jasen/atom-grpc-11-mesh-chat-fields @ fabd2e6: with atom-engine, 1401 lib and 303 integration tests passed. cargo fmt clean; clippy adds no warning of this PR's code.

Follow-ups

none

Stack

ATOM serves atom.grpc.v1.AtomEngine beside its HTTP server (token ids in, token ids out, ATOM's P/D flow unchanged), and atomesh routes to ATOM gRPC workers, over a Generate call per request or one Session per instance. Bottom to top:

  1. [ATOM gRPC] Token-id prompts reuse block-hash chains; an idle EngineCore waits for input (1/14) #3658 Token-id prompts reuse block-hash chains; an idle EngineCore waits for input
  2. [ATOM gRPC] atomesh: share ATOM's P/D rank mapping and prefill-info parsing (2/14) #3659 atomesh: share ATOM's P/D rank mapping and prefill-info parsing
  3. [ATOM gRPC] The atom.grpc.v1 proto and its generated Python modules (3/14) #3660 The atom.grpc.v1 proto and its generated Python modules
  4. [ATOM gRPC] gRPC server: --grpc-port, info RPCs, Generate, Abort, structured output (4/14) #3661 gRPC server: --grpc-port, info RPCs, Generate, Abort, structured output
  5. [ATOM gRPC] gRPC server: the Session RPC and its engine_v1 frames codec (5/14) #3662 gRPC server: the Session RPC and its engine_v1 frames codec
  6. [ATOM gRPC] atomesh: compile ATOM's protos in every build (6/14) #3663 atomesh: compile ATOM's protos in every build
  7. [ATOM gRPC] atomesh: an ATOM gRPC client (7/14) #3664 atomesh: an ATOM gRPC client
  8. [ATOM gRPC] atomesh: discover ATOM gRPC workers, their model info and DP ranks (8/14) #3665 atomesh: discover ATOM gRPC workers, their model info and DP ranks
  9. [ATOM gRPC] atomesh: ATOM P/D over gRPC (9/14) #3666 atomesh: ATOM P/D over gRPC
  10. [ATOM gRPC] atomesh: the Session link to an ATOM instance (10/14) #3667 atomesh: the Session link to an ATOM instance
  11. [ATOM gRPC] atomesh: chat structured output to ATOM; refuse media and Responses (11/14) #3668 atomesh: chat structured output to ATOM; refuse media and Responses
  12. [ATOM gRPC] atomesh: gRPC chat and stream output as ATOM's HTTP routes give it (12/14) #3669 atomesh: gRPC chat and stream output as ATOM's HTTP routes give it
  13. [ATOM gRPC] atomesh: route ATOM requests over the Session (13/14) #3670 atomesh: route ATOM requests over the Session
  14. [ATOM gRPC] The Session's step delivery: Completions without ids, atomesh's Session on its own thread (14/14) #3671 The Session's step delivery: Completions without ids, atomesh's Session on its own thread

1 and 2 stand alone; 6 to 13 need only part 3 of the Python side; 14 changes both sides of the Session.

Evidence

In atom/mesh (rustc and clippy 1.100.0), at fabd2e6:

cargo fmt --check                                         ok
cargo clippy --all-targets                                ok
cargo clippy --all-targets --features atom-engine         ok
cargo check --features ext-proc --tests                   ok
python3 proto/vendor_ext_proc.py --check                  ok
cargo test --features atom-engine --lib                   1401 passed, 0 failed, 7 ignored
cargo test --features atom-engine --test <each> -- --test-threads=1
                                                          303 passed, 0 failed, 1 ignored

Clippy against main cccc96a (warnings matched by message and file):

[clippy] base 108, branch 110, new 2, gone 0
  NEW x2: src/atom_engine/wire.rs: warning: using `chunks_exact` with a constant chunk size
[clippy-ae] base 110, branch 110, new 0, gone 0

Against the PR below (part 10):

[clippy] base 110, branch 110, new 0, gone 0
[clippy-ae] base 110, branch 110, new 0, gone 0

🤖 Generated with Claude Code

… Responses (11/14)

For a chat served by ATOM gRPC workers, atomesh sends ATOM the chat's
structured-output input with the request: tools, tool_choice and
response_format as the client sent them, each message's own tools in
`message_tools_json`, the merged template kwargs the prompt was rendered
with (`merged_template_kwargs`), and whether the rendered prompt ends in
one of the worker's reasoning markers. SGLang and vLLM requests are
unchanged.

For a model with an ATOM gRPC worker, the gRPC routers answer 400
`unsupported_media` to a chat or `/generate` carrying image, video, audio
or embedding input, before preparing it, since ATOM receives only the
rendered token ids; the regular gRPC router answers 501
`unsupported_api` to `/v1/responses` for such a model, and
`/v1/messages` keeps its 501. SGLang and vLLM workers serve media and
Responses as before.

atomesh records how long a gRPC request's chat template and encode take,
as `mesh_prepare_stage_seconds` by stage, beside the HTTP ingress's own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jasen2201

Copy link
Copy Markdown
Collaborator Author

Superseded by #3677 after regrouping by function (see #3657).

@Jasen2201 Jasen2201 closed this Nov 21, 2026
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.

1 participant