Elffuss BraidHub

kikocis/continue public

Merge pull request #7266 from continuedev/dallin/args-streaming-fix

fix HOTFIX remove cumulative args case
Changeset6ef118abeec7300d14b25bc4109f3914d663f7d23996f5e202ea76007bb6f152
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-08-20 18:25 -07:00
CommitterGitHub <noreply@github.com> · 2025-08-20 18:25 -07:00
Parents83c3dc634266, f9200dffb711

Browse the files at this changeset

2 files changed

modified gui/src/util/toolCallState.test.ts +0 −70
@@ -480,76 +480,6 @@
480480 expect(currentState.parsedArgs).toEqual({ location: "Paris, France" });
481481 });
482482
483- it("should handle arguments streamed in full progressive chunks", () => {
484- // Test case where model streams args progressively but includes full prefix each time
485- // e.g. '{"query":"te' -> '{"query":"tes' -> '{"query":"test"}'
486- const currentState: ToolCallState = {
487- status: "generating",
488- toolCall: {
489- id: "call123",
490- type: "function",
491- function: {
492- name: "searchFiles",
493- arguments: '{"query":"te',
494- },
495- },
496- toolCallId: "call123",
497- parsedArgs: { query: "te" },
498- };
499-
500- const delta: ToolCallDelta = {
501- function: {
502- arguments: '{"query":"tes',
503- },
504- };
505-
506- const result = addToolCallDeltaToState(delta, currentState);
507- expect(result.toolCall.function.arguments).toBe('{"query":"tes');
508- expect(result.parsedArgs).toEqual({ query: "tes" });
509-
510- // Continue the streaming
511- const nextDelta: ToolCallDelta = {
512- function: {
513- arguments: '{"query":"test"}',
514- },
515- };
516-
517- const finalResult = addToolCallDeltaToState(nextDelta, result);
518- expect(finalResult.toolCall.function.arguments).toBe('{"query":"test"}');
519- expect(finalResult.parsedArgs).toEqual({ query: "test" });
520- });
521-
522- it("should handle when args delta is a superset of current args", () => {
523- // Test case where model sends a subset of the current arguments
524- // This can happen in certain LLM implementations
525- const currentState: ToolCallState = {
526- status: "generating",
527- toolCall: {
528- id: "call123",
529- type: "function",
530- function: {
531- name: "searchFiles",
532- arguments: '{"query":"test"',
533- },
534- },
535- toolCallId: "call123",
536- parsedArgs: { query: "test" },
537- };
538-
539- const delta: ToolCallDelta = {
540- function: {
541- arguments: '{"query":"test","limit":10}',
542- },
543- };
544-
545- // The subset should be ignored, keeping the current state
546- const result = addToolCallDeltaToState(delta, currentState);
547- expect(result.toolCall.function.arguments).toBe(
548- '{"query":"test","limit":10}',
549- );
550- expect(result.parsedArgs).toEqual({ query: "test", limit: 10 });
551- });
552-
553483 it("should handle when args are complete JSON and new deltas arrive", () => {
554484 // When args are already a valid JSON object, new deltas should not modify it
555485 const currentState: ToolCallState = {
modified gui/src/util/toolCallState.ts +5 −7
@@ -44,13 +44,11 @@
4444 // If args is JSON parseable, it is complete, don't add to it
4545 JSON.parse(currentArgs);
4646 } catch (e) {
47- if (argsDelta.startsWith(currentArgs)) {
48- // Case where model progresssively streams args but full args each time e.g. "{"file": "file1"}" -> "{"file": "file1", "line": 1}"
49- mergedArgs = argsDelta;
50- } else if (!currentArgs.startsWith(argsDelta)) {
51- // Case where model streams in args in parts e.g. "{"file": "file1"" -> ", "line": 1}"
52- mergedArgs = currentArgs + argsDelta;
53- }
47+ // Model streams in args in parts e.g. "{"file": "file1"" -> ", "line": 1}"
48+ mergedArgs = currentArgs + argsDelta;
49+
50+ // Note, removed case where model progresssively streams args but full args each time e.g. "{"file": "file1"}" -> "{"file": "file1", "line": 1}"
51+ // Because no apis do this and difficult to detect reliably
5452 }
5553
5654 const [_, parsedArgs] = incrementalParseJson(mergedArgs || "{}");