feat(session): pass request chat_template_kwargs to apply_chat_template - #1820
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
bf1445c to
9b335c1
Compare
… outbound The session server forwarded request chat_template_kwargs to SGLang but rendered input_ids with the startup tokenizer's kwargs, so a client setting its response mode split the local token stream from SGLang's parser view. Merge the request kwargs over the launch-time values into a request-scoped TITO tokenizer (a clone over the shared HF tokenizer) so the same resolved kwargs drive both the locally rendered input_ids and the outbound SGLang request; family constructors re-derive dependent kwargs (DeepSeek's effective thinking), so a stale derived value never survives the override. Family-fixed history kwargs stay authoritative: a conflicting value fails as a clear 400 via the constructor's fixed-template validation. Known accepted gaps, marked FIXME at the merge site: top-level reasoning/reasoning_effort request fields are not mirrored into the kwargs; mid-session mode-change safety is a per-family property with no guard yet (DeepSeek V3.2/V4 render history under one mode, so a flip strands old-mode prefix tokens, while Nemotron 3 and Qwen3/3.5 carry the setting per turn or only in the generation prompt and are safe — the guard belongs on FixedTemplate); and compute_session_mismatch still renders with the startup tokenizer. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
f2ae6e8 to
f1be8e9
Compare
Keep only the end-to-end request override test, relying on existing constructor coverage for conflicts and derived modes. Shorten the clone overhead note and clarify the SGLang field-mapping FIXME.
…server v2 Add an opt-in tree-serving implementation while keeping the bare flag and v1 on the linear server. SessionState positions each request at the deepest matching node, appends divergent work as branches, supports a strict single-chain guard, and rejects extension of length-truncated paths. The v2 samples operation folds each leaf, applies the picker and merger hooks, masks completions exactly once, joins rewards by response id, and layers fold < agent < server metadata. The core reuses the v1 HTTP plumbing and honors request-scoped TITO template kwargs from the included #1820 changes. Shared seams are inert for v1: route setup dispatches by version and forwards agent metadata only to v2; the codec accepts an explicit field allowlist, with v2 adding reward to the base wire that already carries per-sample metadata; v2-only flags require --use-session-server v2; fixed-template role capabilities remain authoritative; and session verification preserves the explicit version. Tests cover tree search, branching and strict-mode HTTP behavior, truncation and compaction, golden multi-leaf assembly, reward and metadata layering, hook failures, and the unchanged v1 surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
| # - DeepSeek V3.2/V4: unsafe — history think blocks and the | ||
| # prompt-head reasoning_effort marker render under one mode, | ||
| # so a flip strands old-mode prefix tokens and the history no | ||
| # longer matches the requested mode; |
There was a problem hiding this comment.
Nit: it took me a long time to parse this sentence lol. Perhaps ask the agent to rephrase the sentence using clearer terms.
There was a problem hiding this comment.
Updated in e8cc944. I removed the model-by-model discussion and kept the FIXME focused on the current request-shape behavior: only nested chat_template_kwargs reach the local renderer; top-level reasoning and reasoning_effort are not mapped to template kwargs.
There was a problem hiding this comment.
sry I make it too long
|
Actually, is it possible that the server is launched with |
f4f46f6 to
9530a52
Compare
|
Fixed in 9b74231. Request |
Treat DeepSeek mode aliases as one override group when merging request kwargs over startup defaults. This lets request thinking=True replace startup enable_thinking=False while keeping alias validation in the renderer. Co-authored-by: Shi Dong <shi.dong@radixark.ai>
Replace the model-by-model FIXME with the single request-shape constraint enforced by this block. Co-authored-by: Shi Dong <shi.dong@radixark.ai>
9530a52 to
e8cc944
Compare
…server v2 Add an opt-in tree-serving implementation while keeping the bare flag and v1 on the linear server. SessionState positions each request at the deepest matching node, appends divergent work as branches, supports a strict single-chain guard, and rejects extension of length-truncated paths. The v2 samples operation folds each leaf, applies the picker and merger hooks, masks completions exactly once, joins rewards by response id, and layers fold < agent < server metadata. The core reuses the v1 HTTP plumbing and honors request-scoped TITO template kwargs from the included #1820 changes. Shared seams are inert for v1: route setup dispatches by version and forwards agent metadata only to v2; the codec accepts an explicit field allowlist, with v2 adding reward to the base wire that already carries per-sample metadata; v2-only flags require --use-session-server v2; fixed-template role capabilities remain authoritative; and session verification preserves the explicit version. Tests cover tree search, branching and strict-mode HTTP behavior, truncation and compaction, golden multi-leaf assembly, reward and metadata layering, hook failures, and the unchanged v1 surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…server v2 Add an opt-in tree-serving implementation while keeping the bare flag and v1 on the linear server. SessionState positions each request at the deepest matching node, appends divergent work as branches, supports a strict single-chain guard, and rejects extension of length-truncated paths. The v2 samples operation folds each leaf, applies the picker and merger hooks, masks completions exactly once, joins rewards by response id, and layers fold < agent < server metadata. The core reuses the v1 HTTP plumbing and honors request-scoped TITO template kwargs from the included #1820 changes. Shared seams are inert for v1: route setup dispatches by version and forwards agent metadata only to v2; the codec accepts an explicit field allowlist, with v2 adding reward to the base wire that already carries per-sample metadata; v2-only flags require --use-session-server v2; fixed-template role capabilities remain authoritative; and session verification preserves the explicit version. Tests cover tree search, branching and strict-mode HTTP behavior, truncation and compaction, golden multi-leaf assembly, reward and metadata layering, hook failures, and the unchanged v1 surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…server v2 Add an opt-in tree-serving implementation while keeping the bare flag and v1 on the linear server. SessionState positions each request at the deepest matching node, appends divergent work as branches, and rejects extension of length-truncated paths. The v2 samples operation folds each leaf, applies the picker and merger hooks, masks completions exactly once, joins rewards by response id, and layers fold < agent < server metadata. The core reuses the v1 HTTP plumbing and honors request-scoped TITO template kwargs from the included #1820 changes. Shared seams are inert for v1: route setup dispatches by version and forwards agent metadata only to v2; the codec accepts an explicit field allowlist, with v2 adding reward to the base wire that already carries per-sample metadata; v2-only flags require --use-session-server v2; fixed-template role capabilities remain authoritative; and session verification preserves the explicit version. Tests cover tree search, branching HTTP behavior, truncation and compaction, golden multi-leaf assembly, reward and metadata layering, hook failures, and the unchanged v1 surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…server v2 Add an opt-in tree-serving implementation while keeping the bare flag and v1 on the linear server. SessionState positions each request at the deepest matching node, appends divergent work as branches, and rejects extension of length-truncated paths. The v2 samples operation folds each leaf, applies the picker and merger hooks, masks completions exactly once, joins rewards by response id, and layers fold < agent < server metadata. The core reuses the v1 HTTP plumbing and honors request-scoped TITO template kwargs from the included #1820 changes. Shared seams are inert for v1: route setup dispatches by version and forwards agent metadata only to v2; the codec accepts an explicit field allowlist, with v2 adding reward to the base wire that already carries per-sample metadata; v2-only flags require --use-session-server v2; fixed-template role capabilities remain authoritative; and session verification preserves the explicit version. Tests cover tree search, branching HTTP behavior, truncation and compaction, golden multi-leaf assembly, reward and metadata layering, hook failures, and the unchanged v1 surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…server v2 Add an opt-in tree-serving implementation while keeping the bare flag and v1 on the linear server. SessionState positions each request at the deepest matching node, appends divergent work as branches, and rejects extension of length-truncated paths. The v2 samples operation folds each leaf, applies the picker and merger hooks, masks completions exactly once, joins rewards by response id, and layers fold < agent < server metadata. The core reuses the v1 HTTP plumbing and honors request-scoped TITO template kwargs from the included #1820 changes. Shared seams are inert for v1: route setup dispatches by version and forwards agent metadata only to v2; the codec accepts an explicit field allowlist, with v2 adding reward to the base wire that already carries per-sample metadata; v2-only flags require --use-session-server v2; fixed-template role capabilities remain authoritative; and session verification preserves the explicit version. Tests cover tree search, branching HTTP behavior, truncation and compaction, golden multi-leaf assembly, reward and metadata layering, hook failures, and the unchanged v1 surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…server v2 Add an opt-in tree-serving implementation while keeping the bare flag and v1 on the linear server. SessionState positions each request at the deepest matching node, appends divergent work as branches, and rejects extension of length-truncated paths. The v2 samples operation folds each leaf, applies the picker and merger hooks, masks completions exactly once, joins rewards by response id, and layers fold < agent < server metadata. The core reuses the v1 HTTP plumbing and honors request-scoped TITO template kwargs from the included #1820 changes. Shared seams are inert for v1: route setup dispatches by version and forwards agent metadata only to v2; the codec accepts an explicit field allowlist, with v2 adding reward to the base wire that already carries per-sample metadata; v2-only flags require --use-session-server v2; fixed-template role capabilities remain authoritative; and session verification preserves the explicit version. Tests cover tree search, branching HTTP behavior, truncation and compaction, golden multi-leaf assembly, reward and metadata layering, hook failures, and the unchanged v1 surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…server v2 Add an opt-in tree-serving implementation while keeping the bare flag and v1 on the linear server. SessionState positions each request at the deepest matching node, appends divergent work as branches, and rejects extension of length-truncated paths. The v2 samples operation folds each leaf, applies the picker and merger hooks, masks completions exactly once, joins rewards by response id, and layers fold < agent < server metadata. The core reuses the v1 HTTP plumbing and honors request-scoped TITO template kwargs from the included #1820 changes. Shared seams are inert for v1: route setup dispatches by version and forwards agent metadata only to v2; the codec accepts an explicit field allowlist, with v2 adding reward to the base wire that already carries per-sample metadata; v2-only flags require --use-session-server v2; fixed-template role capabilities remain authoritative; and session verification preserves the explicit version. Tests cover tree search, branching HTTP behavior, truncation and compaction, golden multi-leaf assembly, reward and metadata layering, hook failures, and the unchanged v1 surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
Pass request
chat_template_kwargstoapply_chat_templatewhen rendering sessioninput_ids.Motivation
Session requests accepted
chat_template_kwargs, but localapply_chat_templatecalls did not receive them.Usage
For this request, Miles passes
enable_thinking=falsetoapply_chat_templatewhile renderinginput_ids.Request values replace matching startup
chat_template_kwargsfor this render.A request value that conflicts with a model family's fixed value returns HTTP 400.
Design Notes
SessionCore.chat_completionsmerges request values over startupchat_template_kwargs.TITOTokenizer.clone_with_chat_template_kwargscreates a request-scoped tokenizer over the same HF tokenizer.TITOTokenizer.apply_chat_templatepasses the merged values totemplate.apply_chat_template.Verification
test_chat_template_kwargs_override_reaches_render_and_backendverifies a request override changes locally renderedinput_ids.Review Focus
SessionCore.chat_completions.TITOTokenizer.clone_with_chat_template_kwargspreserves required model-family state.