Elffuss BraidHub

kikocis/continue public

fix: remove unecessary serve callbacks
Changeseta9ed471f6c5a80101907f4af5ccb5fdefd7d12f91c885abdf18463b6b0b60b6e
AuthorNate <sestinj@gmail.com> · 2025-08-28 19:18 -07:00
CommitterNate <sestinj@gmail.com> · 2025-08-28 19:18 -07:00
Parents1bedc7304a64

Browse the files at this changeset

1 file changed

modified extensions/cli/src/commands/serve.helpers.ts +16 −78
@@ -1,4 +1,4 @@
1-import type { Session, ToolCallState, ToolStatus } from "core/index.js";
1+import type { Session, ToolStatus } from "core/index.js";
22
33 import { streamChatResponse } from "../stream/streamChatResponse.js";
44 import { StreamCallbacks } from "../stream/streamChatResponse.types.js";
@@ -33,87 +33,25 @@
3333 // so we don't need to add them here - this callback is just for notification
3434 // that content streaming is complete
3535 },
36- onToolStart: (toolName: string, toolArgs?: any) => {
37- // Always create a new assistant message for each tool call
38- const toolCallId = `tool_${Date.now()}_${Math.random().toString(36).substring(2, 15)}`;
39- const toolCall = {
40- id: toolCallId,
41- type: "function" as const,
42- function: {
43- name: toolName,
44- arguments: JSON.stringify(toolArgs || {}),
45- },
46- };
47- const toolCallState: ToolCallState = {
48- toolCallId: toolCallId,
49- toolCall: toolCall,
50- status: "calling",
51- parsedArgs: toolArgs,
52- };
53-
54- state.session.history.push({
55- message: {
56- role: "assistant",
57- content: "",
58- toolCalls: [toolCall],
59- },
60- contextItems: [],
61- toolCallStates: [toolCallState],
62- });
36+ onToolStart: (__: string, _?: any) => {
37+ // Note: handleToolCalls already adds the tool call message to history
38+ // This callback is just for notification/UI updates
39+ // The tool call state is already created and added by handleToolCalls
6340 },
64- onToolResult: (result: string, toolName: string, status: ToolStatus) => {
65- // Find and update the corresponding tool call state
66- for (let i = state.session.history.length - 1; i >= 0; i--) {
67- const item = state.session.history[i];
68- if (item.toolCallStates) {
69- const toolState = item.toolCallStates.find(
70- (ts: ToolCallState) =>
71- ts.toolCall.function.name === toolName && ts.status === "calling",
72- );
73- if (toolState) {
74- toolState.status = status;
75- toolState.output = [
76- {
77- content: result,
78- name: `Tool Result: ${toolName}`,
79- description: "Tool execution result",
80- },
81- ];
82- break;
83- }
84- }
85- }
41+ onToolResult: (_: string, __: string, ___: ToolStatus) => {
42+ // Note: handleToolCalls already updates the tool call states in history
43+ // This callback is just for notification/UI updates
8644 },
8745 onToolError: (error: string, toolName?: string) => {
88- if (toolName) {
89- // Find and update the corresponding tool call state
90- for (let i = state.session.history.length - 1; i >= 0; i--) {
91- const item = state.session.history[i];
92- if (item.toolCallStates) {
93- const toolState = item.toolCallStates.find(
94- (ts: ToolCallState) =>
95- ts.toolCall.function.name === toolName &&
96- ts.status === "calling",
97- );
98- if (toolState) {
99- toolState.status = "errored";
100- toolState.output = [
101- {
102- content: error,
103- name: `Tool Error: ${toolName}`,
104- description: "Tool execution error",
105- },
106- ];
107- break;
108- }
109- }
110- }
46+ // Note: handleToolCalls and preprocessStreamedToolCalls already handle errors
47+ // This callback is just for notification/UI updates
48+ // If we need to display a generic error message (no tool name), add it
49+ if (!toolName) {
50+ state.session.history.push({
51+ message: { role: "system", content: error },
52+ contextItems: [],
53+ });
11154 }
112- // Generic error if tool not found
113- state.session.history.push({
114- message: { role: "system", content: error },
115- contextItems: [],
116- });
11755 },
11856 onToolPermissionRequest: (
11957 toolName: string,