Skip to content

Commit af5a130

Browse files
danielholandagithub-actions[bot]Wauplin
authored andcommitted
[MCP] Fix vestigial token yield on early exit (#3132)
* Don't yield tokens on early exit * Apply style fixes --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Lucain <[email protected]>
1 parent 2e6336e commit af5a130

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/huggingface_hub/inference/_mcp/mcp_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,6 @@ async def process_single_turn_with_tools(
272272

273273
# Read from stream
274274
async for chunk in response:
275-
# Yield each chunk to caller
276-
yield chunk
277-
278275
num_of_chunks += 1
279276
delta = chunk.choices[0].delta if chunk.choices and len(chunk.choices) > 0 else None
280277
if not delta:
@@ -304,6 +301,9 @@ async def process_single_turn_with_tools(
304301
if exit_if_first_chunk_no_tool and num_of_chunks <= 2 and len(final_tool_calls) == 0:
305302
return
306303

304+
# Yield each chunk to caller
305+
yield chunk
306+
307307
if message["content"]:
308308
messages.append(message)
309309

0 commit comments

Comments
 (0)