Skip to content

[Bug]: Eagle3 speculative decoding silently drops tool_calls for gpt-oss on trtllm-serve #16377

Open

Description

@NPB2026

System Info

[Bug] Eagle3 speculative decoding silently drops tool_calls for gpt-oss on trtllm-serve

Summary

With gpt-oss-120b on trtllm-serve, enabling Eagle3 speculative decoding makes the server
return an empty tool_calls array and empty content, even though the model clearly decided
to call the function (its reasoning_content says so, and it emitted the tokens).

Disabling speculative decoding — changing nothing else — makes tool calling work correctly.

The Harmony adapter itself is active in both cases (reasoning_content is populated either way), so
this is not a model-detection or chat-template problem: the tool-call channel is lost specifically
when Eagle3 is on.

This may be the missing link between #8615 and #10612

Two open issues describe what look like the same underlying failure, seen from different angles:

Our A/B adds the missing variable: Eagle3 is the trigger, and the damage lands on the Harmony
control tokens — which are exactly the rare, structural tokens a draft head is worst at predicting
(<|channel|>, <|message|>).

Our failure mode is the most dangerous of the three, because it is completely silent. #8615 loops
loudly; #10612 returns visibly malformed JSON. Here: HTTP 200, finish_reason: "stop", no warning —
the tool call simply is not there. A framework cannot tell this apart from "the model chose not to call
the tool".

(#7163 is closed and used xgrammar with no speculative_config, so it is a different path.)

Environment

Container nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc13
GPU NVIDIA GB10 (DGX Spark), compute capability sm_121
Driver 580.159.03
Backend --backend pytorch, --tp_size 1
Model openai/gpt-oss-120b (MXFP4)
Draft model nvidia/gpt-oss-120b-Eagle3-long-context

Reproduction

A — WITH Eagle3 → tool_calls is empty (bug)

extra-llm-api-config.yml:

enable_attention_dp: false
disable_overlap_scheduler: false
enable_autotuner: false
cuda_graph_config:
    max_batch_size: 4
speculative_config:
    decoding_type: Eagle
    max_draft_len: 5
    speculative_model_dir: /opt/gpt-oss-120b-Eagle3/
kv_cache_config:
    free_gpu_memory_fraction: 0.9
    enable_block_reuse: false
trtllm-serve openai/gpt-oss-120b \
  --tokenizer <local snapshot path> \
  --backend pytorch --tp_size 1 --max_batch_size 4 \
  --host 0.0.0.0 --port 8005 \
  --extra_llm_api_options extra-llm-api-config.yml

Request:

curl -s http://127.0.0.1:8005/v1/chat/completions -H 'Content-Type: application/json' -d '{
  "model":"openai/gpt-oss-120b",
  "messages":[{"role":"user","content":"What is the weather in Rome? Use the tool."}],
  "tools":[{"type":"function","function":{
      "name":"get_weather","description":"Get the weather of a city",
      "parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}}],
  "tool_choice":"auto","max_tokens":300}'

Response (bug):

{
  "message": {
    "role": "assistant",
    "content": "",
    "reasoning_content": "User asks weather in Rome. Use function.",
    "tool_calls": []
  },
  "finish_reason": "stop",
  "usage": { "completion_tokens": 37 }
}

Note: completion_tokens: 37 while the reasoning text is only ~10 words — the tool-call tokens were
generated and then dropped
. reasoning_content being populated proves the Harmony adapter is active
(openai_server.py: use_harmony = (model_config.model_type == "gpt_oss")).

B — WITHOUT Eagle3 → works

Same command, same image, same model, same tokenizer, same request. Only the config differs — the
speculative_config block is removed:

enable_attention_dp: false
disable_overlap_scheduler: false
enable_autotuner: false
cuda_graph_config:
    max_batch_size: 4
kv_cache_config:
    free_gpu_memory_fraction: 0.9
    enable_block_reuse: false

Response (correct):

{
  "tool_calls": [
    { "function": { "name": "get_weather", "arguments": "{\"city\": \"Rome\"}" } }
  ]
}

Why this matters

The failure is silent: HTTP 200, finish_reason: "stop", no warning in the logs. An agent
framework sees an assistant message with empty content and no tool call, and simply believes the model
declined to act. Any multi-agent system built on tool calling will appear to "work" while doing
nothing — which is how we spent hours blaming the model.

Also worth noting: the DGX Spark playbook
(dgx-spark-playbooks/nvidia/speculative-decoding, Option 1) recommends exactly this Eagle3 recipe for
gpt-oss-120b on a single Spark. Anyone following it and then using tools will hit this.

Suggested area to look at

tensorrt_llm/serve/harmony_adapter.py — the token-batch path
(process_token_batch / _get_or_create_tool_call) versus how tokens are delivered when
Eagle3OneModelSampler is in use. The reasoning channel survives; the tool-call channel does not.

A loud error — or even a startup warning that tool calling is unsupported with speculative decoding —
would already be a large improvement over silently returning an empty tool_calls.

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

Container nvcr.io/nvidia/tensorrt-llm/release:1.3.0rc13
GPU NVIDIA GB10 (DGX Spark), compute capability sm_121
Driver 580.159.03
Backend --backend pytorch, --tp_size 1
Model openai/gpt-oss-120b (MXFP4)
Draft model nvidia/gpt-oss-120b-Eagle3-long-context

A — WITH Eagle3 → tool_calls is empty (bug)

config.yml:

enable_attention_dp: false
disable_overlap_scheduler: false
enable_autotuner: false
cuda_graph_config:
    max_batch_size: 4
speculative_config:
    decoding_type: Eagle
    max_draft_len: 5
    speculative_model_dir: /opt/gpt-oss-120b-Eagle3/
kv_cache_config:
    free_gpu_memory_fraction: 0.9
    enable_block_reuse: false

Server:

trtllm-serve openai/gpt-oss-120b \
  --tokenizer <path to the local HF snapshot> \
  --backend pytorch --tp_size 1 --max_batch_size 4 \
  --host 0.0.0.0 --port 8000 \
  --extra_llm_api_options config.yml

Request:

curl -s http://localhost:8000/v1/chat/completions -H 'Content-Type: application/json' -d '{
  "model": "openai/gpt-oss-120b",
  "messages": [{"role": "user", "content": "What is the weather in Rome? Use the tool."}],
  "tools": [{"type": "function", "function": {
      "name": "get_weather",
      "description": "Get the weather of a city",
      "parameters": {"type": "object",
                     "properties": {"city": {"type": "string"}},
                     "required": ["city"]}}}],
  "tool_choice": "auto",
  "max_tokens": 300}'

B — WITHOUT Eagle3 → works

Same image, same model, same tokenizer, same request. Only the speculative_config block is removed
from config.yml.


---


### Expected behavior

```markdown
The response should contain the tool call the model decided to make — which is exactly what happens
when Eagle3 is disabled:

```json
{
  "message": {
    "role": "assistant",
    "tool_calls": [
      {"function": {"name": "get_weather", "arguments": "{\"city\": \"Rome\"}"}}
    ]
  }
}

---


### actual behavior

```markdown
With Eagle3 enabled, the tool call is silently lost:

```json
{
  "message": {
    "role": "assistant",
    "content": "",
    "reasoning_content": "User asks weather in Rome. Use function.",
    "tool_calls": []
  },
  "finish_reason": "stop",
  "usage": { "completion_tokens": 37 }
}

Three things are worth pointing out:

  1. The model did decide to call the function — reasoning_content literally says "Use function."
  2. completion_tokens: 37, while the reasoning text is only ~10 words. The tool-call tokens were
    generated and then dropped.
  3. The Harmony adapter is active — reasoning_content being populated proves it
    (openai_server.py: use_harmony = (model_config.model_type == "gpt_oss")). So this is not a
    model-detection or chat-template problem.

There is no error, no warning, and finish_reason is "stop". The response is a perfectly valid
HTTP 200. An agent framework cannot distinguish this from "the model chose not to call the tool".


---


### additional notes

```markdown
### This may be the missing link between #8615 and #10612

Two **open** issues look like the same underlying failure seen from different angles:

- **#8615** (*Investigating*) — speculative decoding with `gpt-oss-120b-Eagle3` produces **corrupted
  channel tokens** (`<|channel|>!!!!!!!!!!!!…`) and an infinite loop.
- **#10612** (*open*) — the Harmony **channel-establishment sequence**
  (`<|channel|>final<|message|>`, token IDs `200005`, `17196`, `200008`) **is not generated**, the
  parser hits *"Unexpected EOS while waiting for message header to complete"*, and falls back to
  corrupted or empty output.

The A/B above adds the missing variable: **Eagle3 is the trigger**, and the damage lands on the Harmony
**control tokens** — precisely the rare, structural tokens (`<|channel|>`, `<|message|>`) that a draft
head is worst at predicting.

**This failure mode is the most dangerous of the three, because it is completely silent.** #8615 loops
loudly; #10612 returns visibly malformed JSON. Here everything looks fine and the tool call is simply
absent.

(#7163 is closed and used xgrammar with **no** `speculative_config` — a different path.)

### Suggested area to look at

`tensorrt_llm/serve/harmony_adapter.py` — the token-batch path (`process_token_batch` /
`_get_or_create_tool_call`) versus how tokens are delivered when `Eagle3OneModelSampler` is in use.
The reasoning channel survives; the tool-call channel does not.

### Why this matters beyond one user

The official DGX Spark playbook (`dgx-spark-playbooks/nvidia/speculative-decoding`, Option 1)
recommends **exactly this Eagle3 recipe** for gpt-oss-120b on a single Spark. Anyone who follows it and
then uses tools will hit this — and, because it is silent, will likely blame the model.

Even just a startup warning ("tool calling is not supported with speculative decoding") would be a large
improvement over returning an empty `tool_calls` with HTTP 200.

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.

Activity

  1. added
    bug
    on Jul 14, 2026
  2. added
    Inference runtime
    Speculative Decoding
    Pytorch
    on Jul 14, 2026
  3. Saad-Mallebhari commented on Aug 7, 2026

    @Saad-Mallebhari

    Hi @NPB2026

    Thanks for the detailed A/B test breakdown and cross-referencing with #8615 and #10612.

    Your findings pinpoint how speculative draft acceptance interacts with Harmony channel parsing. gpt-oss relies on structural control tokens (<|channel|>final<|message|>, token IDs 200005, 17196, 200008) to transition tensorrt_llm/serve/harmony_adapter.py from reasoning_content parsing into _get_or_create_tool_call buffering.

    When Eagle3OneModelSampler verifies and emits accepted token batches in trtllm-serve, draft token acceptance and verification slice extraction bypasses the channel state transition events expected by process_token_batch(). The reasoning channel populates because it precedes the structural control tokens, but the subsequent tool-call tokens fail channel classification and are silently dropped, returning HTTP 200 with an empty tool_calls array.

    Ensuring harmony_adapter.py's token stream parser receives un-batched control token boundaries during speculative draft verification would prevent silent tool-call drop.

  4. mshayeb commented on Nov 10, 2026

    @mshayeb

    Hi, I'd like to take on the root cause here. #17464 stops Harmony from discarding malformed tool-call messages, and #17439 adds a warning. Neither explains why the call is lost only when Eagle3 is enabled.

    My plan:

    1. CPU-only repro. Feed the same Harmony token sequence into harmony_adapter.py (process_token_batch) at batch size 1 and at batch sizes 2–6, including cases where <|call|> or the <|channel|>…<|message|> prelude lands mid-batch.
    2. Fix and test. If that reproduces the drop, fix the batch handling and add a regression test parameterized over batch size.
    3. End-to-end check. Confirm on an L40S with gpt-oss-20b + an Eagle3 draft, and cross-check against the acceptance-side analysis in [Bug]: Interior control-token rejection can split a tool-call prelude and silently drop tool_calls #17437.

    I'll post findings here as I go. Could a maintainer assign this to me?

  5. mshayeb commented on Nov 10, 2026

    @mshayeb

    Findings: CPU repro, batch handling, and Eagle3 accept path

    TL;DR: Batching in harmony_adapter.py is not what loses the tool call. A malformed prelude loses it even at batch size 1. I found and fixed a smaller batch-size bug along the way: valid streamed content was dropped when the parser errors. On the Eagle3 side, I couldn't run gpt-oss-20b on an L40S. A Qwen3-8B + Eagle3 proxy run on the L40S showed no accept-side corruption. The gpt-oss Eagle3 draft can't propose <|constrain|>, <|call|> or <|return|>, which keeps #17437's mechanism plausible but unconfirmed.

    Environment: TensorRT-LLM main @ a0ce6c8474 (1.4.0rc3), NVIDIA L40S (SM89), one-model Eagle3, max_draft_len=3.

    1. CPU repro: batch size

    I fed Harmony token sequences through create_openai_streaming_response → process_token_batch in every schedule below, put the deltas back together the way an OpenAI client would, and compared against batch size 1 and against harmony_output_to_openai:

    • batch sizes 1–6, with every offset;
    • every two-way split point, so <|call|> and each prelude token land mid-batch;
    • the whole sequence as a single batch.
    Case Tool call (bs=1 / non-streaming) Schedules that differ from bs=1
    analysis → tool call ✅ / ✅ 0 / 56
    analysis → preamble → tool call ✅ / ✅ 0 / 66
    tool call on analysis channel ✅ / ✅ 0 / 55
    analysis → final n/a 0 / 42
    missing <|message|> (no parser error) ❌ / ❌ 0 / 55
    missing <|start|> (HarmonyError) ❌ / ❌ 41 / 54
    broken channel header (HarmonyError) ❌ / ❌ 20 / 54
    duplicated <|start|> ✅ / ✅ 0 / 57
    • Well-formed sequences give the same output at every batch size and split. process_token_batch feeds the parser one token at a time, and the non-streaming path parses the whole sequence at once with no batching at all.
    • A malformed prelude loses the tool call at every batch size, in both streaming and non-streaming. A missing <|message|> is the worst case: the parser raises nothing, and the call just never appears.

    2. Secondary bug: streaming dropped valid content (fix ready)

    When the parser raised a HarmonyError, stateful_stream_harmony_tokens_to_openai_deltas returned [] for the whole batch. That threw away the deltas of valid tokens earlier in the same batch, and the tokens after the bad one were never processed. Larger batches lose more, which is why Eagle3 is hit harder. Example: with a split after token 4, the streamed reasoning comes out as just "User" instead of the full sentence.

    The fix rejects only the token that caused the error, in both process_token_batch and process_token_batch_to_messages. A new CPU test (test_harmony_batch_invariance.py, registered in l0_cpu.yml) requires identical output for every schedule. Without the fix, 2 of its cases fail; with it, all 91 harmony unit tests pass. PR to follow.

    This fix does not bring back a tool call from a malformed sequence. It only makes streaming output independent of batch size.

    3. gpt-oss Eagle3 draft vocabulary

    The Eagle3 draft I checked (zhuyksir/EAGLE3-gpt-oss-20b-bf16) has a 32k reduced vocabulary, mapped to the target's through d2t/t2d. Which Harmony control tokens it includes:

    Token In draft vocab
    <|start|>, <|channel|>, <|message|>, <|end|> ✅
    <|constrain|>, <|call|>, <|return|> ❌

    <|constrain|> sits in the middle of every JSON tool-call prelude (… to=functions.x <|constrain|>json<|message|>…). So with Eagle3, it can only come from the target's correction step, always at a rejection point, with the draft continuing from there. This matches the setup #17437 describes. The draft used in the original report may differ; it would be worth checking its t2d the same way.

    4. Accept/commit path (code reading)

    Both host-side commit paths check the stop criteria after each accepted token and break, so tokens shouldn't leak past <|call|>:

    • TorchSampler._process_draft_tokens (two-model path);
    • SpecSamplerBase.update_requests → handle_stop_criteria (one-model path).

    I didn't find any code that rejects or rewrites control tokens specifically.

    5. End-to-end on L40S

    gpt-oss-20b can't run on an L40S (SM89) with current main:

    • Its W4A16_MXFP4 MoE layers are only supported by Cutlass and Triton on SM90, and by TRTLLM-Gen on SM100+.
    • On SM89, the only backend that can load gpt-oss's expert bias and clamped SwiGLU is unquantized Cutlass. In BF16 the model needs about 42 GB, which doesn't fit in 46 GB alongside the KV cache and the draft.

    So step 3 of the plan needs an SM90+ GPU.

    Proxy on the L40S: Qwen3-8B + Eagle3 (Tengyunw/qwen3_8b_eagle3). </tool_call> is set as a stop token to mimic <|call|>. As with gpt-oss, <tool_call> and </tool_call> are not in this draft's vocabulary. I ran 160 completions per config: 16 prompts, thinking on and off, greedy plus 4 sampled at temperature 0.8.

    base Eagle3 (exact-match) Eagle3 (use_rejection_sampling)
    Mean tokens per step 0.99 2.26 2.19
    Tokens after the stop token 0 0 0
    Tool-call tags spelled as plain text 0 0 0
    Malformed tool calls (not truncation) 0 0 0
    Greedy token-identical to base — 24/32 22/32
    • The only invalid calls came from one prompt that hit max_tokens, and the baseline hit it too.
    • Every greedy divergence starts inside the <think> text, and each diverging pair still ends in the same valid tool call. I put these down to floating-point differences when several tokens are verified in one pass, but I haven't ruled out anything else.

    Where this leaves the root cause

    • Batch handling in the adapter isn't the cause; it only made the loss worse in streaming, and that part is fixed.
    • The generic Eagle3 accept/commit path didn't corrupt tool-call structure in a setup that has the same "control token outside the draft vocab" property.
    • What's left is specific to gpt-oss, and the strongest lead is <|constrain|> being impossible for the draft to propose.

    What would settle it: the raw output token_ids for one failing request with Eagle3, and the same request with Eagle3 off at temperature=0. If anyone has these from the original report, please share them. Otherwise I'll run the same capture on an SM90 GPU and post the diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Inference runtimePytorchSpeculative Decodingbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions