[Bug]: gpt-oss streaming chat ends tool-call turns with finish_reason "stop" instead of "tool_calls"
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- backend-api-design
Direzione di ricerca
Start in tensorrt_llm/serve/harmony_adapter.py, reading handle_streaming_response and how HarmonyStreamState.tool_calls tracks filtered calls; compare with _determine_finish_reason and chat_stream_post_processor. Reproduce with the CPU-only snippet in the issue. Done when the final streamed chunk reports tool_calls for a tool-call turn, matching non-streaming behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
System Info
main at 6c18d93134, trtllm-serve with a gpt-oss model (Harmony chat path). The defect is in tensorrt_llm/serve/harmony_adapter.py and does not depend on the GPU.
Information
- The official example scripts
Reproduction
A streamed chat request in which the model calls a tool:
POST /v1/chat/completions
{"model": "<gpt-oss model>", "stream": true,
"messages": [{"role": "user", "content": "What is the weather in SF?"}],
"tools": [{"type": "function", "function": {"name": "get_weather",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}}}}]}
CPU-only reproduction of the streaming path with the real Harmony encoding:
from unittest.mock import Mock
from tensorrt_llm.serve.harmony_adapter import get_harmony_adapter, handle_streaming_response
tokens = get_harmony_adapter().encoding.encode(
'<|channel|>commentary to=functions.get_weather <|constrain|>json'
'<|message|>{"city":"SF"}<|call|>', allowed_special="all")
def response(token_ids_diff, done):
output = Mock(token_ids_diff=token_ids_diff, token_ids=tokens, finish_reason="stop",
stop_reason=None, disaggregated_params=None)
return Mock(outputs=[output], _done=done, cached_tokens=0)
chunks = handle_streaming_response(tools=[], tool_choice=None, result=response(tokens[:-1], False),
model="m", request_id="r", done=False, num_prompt_tokens=5,
first_iteration=True)
chunks += handle_streaming_response(tools=[], tool_choice=None, result=response(tokens[-1:], True),
model="m", request_id="r", done=True, num_prompt_tokens=5,
first_iteration=False)
The chunks stream the get_weather tool call, and the last choice chunk has "finish_reason": "stop".
Expected behavior
The stream ends with "finish_reason": "tool_calls", as the same request without streaming does (handle_non_streaming_response uses _determine_finish_reason), and as the chat stream of every other model does (chat_stream_post_processor turns "stop" into "tool_calls" when the turn had a tool call).
actual behavior
handle_streaming_response builds the final chunk with finish_reason=output.finish_reason. A gpt-oss tool call ends at the <|call|> stop token, so that is always "stop". The chunk that create_openai_streaming_response emits when it cuts a stream short (should_stop) is also hard-coded to "stop".
OpenAI-compatible agent clients decide whether to run the tool loop from finish_reason == "tool_calls", so with streaming they treat the tool call turn as a finished answer.
additional notes
The streaming state already tracks the tool calls a request has streamed (HarmonyStreamState.tool_calls, which holds only the calls that passed tool filtering), so the finish reason can be derived from it. Draft PR #21735 moves gpt-oss chat onto the shared chat handler but keeps chat_harmony_streaming_post_processor and this function, so the behavior is the same there. I have a fix and will open a PR.
- Lingua principale
- Python
- Stelle
- 15.2k
- Fork
- 3k
- Merge medio
- 2g 21h
- PR unite (30g)
- 477
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di NVIDIA/TensorRT-LLM
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.xForse già presa @NimaVaziri l’ha presa oggi. ApertaPytorch
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NVIDIA/TensorRT-LLM#23406 ·
I maintainer di solito rispondono entro 1 giorno
-
Inference runtime Windows
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
NVIDIA/TensorRT-LLM#23394 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: MMLU subsampling changes when evaluators are interleavedForse già presa @LeNeLeNeWo l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
NVIDIA/TensorRT-LLM#23273 ·
I maintainer di solito rispondono entro 1 giorno
-
Trace-replay Pareto window includes the drain when sessions finish out of admission orderForse già presa @sbeierle l’ha presa 3 giorni fa. ApertaTesting
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
NVIDIA/TensorRT-LLM#23077 ·
I maintainer di solito rispondono entro 1 giorno
-
LongBench V2 blog command breaks on inline comments after continuationsForse già presa @ddlw l’ha presa 25 giorni fa. ApertaDoc
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
NVIDIA/TensorRT-LLM#21879 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di NVIDIA/TensorRT-LLM
Issue simili
-
[Resource]: SpaicelyApertaresource-submission validation-passed
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
hesreallyhim/awesome-claude-code#3875 · 1 commento ·
-
[Bug]: Ajax Pro login issueApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
bvis/aegis-hass#725 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
datasektionen/cashflow#468 ·
-
dont call alembic upgrade until we check whether or not the cache DB has an alembic version stampAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
#1643 unrecoverable split: 1 digest with a 403 — two earlier captures of the same URL are real 200sAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
Robin-IA/Congressional-Letters-Dev#1684 ·
I maintainer di solito rispondono entro 1 giorno