Content-Length: 276931 | pFad | http://github.com/huggingface/huggingface.js/commit/6e5ac81363cd5f6ce82e47faad5ee99976f1ef31

66 [MCP] fix: stray token leak when early-exit is triggered (#1508) · huggingface/huggingface.js@6e5ac81 · GitHub
Skip to content

Commit 6e5ac81

Browse files
[MCP] fix: stray token leak when early-exit is triggered (#1508)
similar PR to huggingface/huggingface_hub#3132. as explained by @danielholanda in the PR, when `opts.exitIfFirstChunkNoTool` is `True`, the CLI is supposed to abort streaming if the first chunk contains no tool call. However, we currently yield the first chunk before checking the exit condition, so a "vestigial" token still reached the user. This PR fixes this behavior.
1 parent 9401982 commit 6e5ac81

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/mcp-client/src/McpClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ export class McpClient {
145145
if (opts.abortSignal?.aborted) {
146146
throw new Error("AbortError");
147147
}
148-
yield chunk;
149148
debug(chunk.choices[0]);
150149
numOfChunks++;
151150
const delta = chunk.choices[0]?.delta;
@@ -174,6 +173,7 @@ export class McpClient {
174173
//github.com/ If no tool is present in chunk number 1 or 2, exit.
175174
return;
176175
}
176+
yield chunk;
177177
}
178178

179179
messages.push(message);

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/huggingface/huggingface.js/commit/6e5ac81363cd5f6ce82e47faad5ee99976f1ef31

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy