Skip to content

Commit e1cb41d

Browse files
committed
fix: resolve syntax error and remove obsolete completeSubtask tests
- Fix missing closing bracket in delegateParentAndOpenChild call in Task.ts - Remove completeSubtask test block which tests removed functionality (replaced by metadata-driven delegation)
1 parent a9ed47b commit e1cb41d

File tree

2 files changed

+1
-149
lines changed

2 files changed

+1
-149
lines changed

src/core/task/Task.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
19301930
message,
19311931
initialTodos,
19321932
mode,
1933+
})
19331934
return child
19341935
}
19351936

src/core/task/__tests__/Task.spec.ts

Lines changed: 0 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,153 +1966,4 @@ describe("Queued message processing after condense", () => {
19661966
expect(spyB).toHaveBeenCalledWith("B message", undefined)
19671967
expect(taskB.messageQueueService.isEmpty()).toBe(true)
19681968
})
1969-
1970-
describe("completeSubtask native protocol handling", () => {
1971-
let mockProvider: any
1972-
let mockApiConfig: any
1973-
1974-
beforeEach(() => {
1975-
vi.clearAllMocks()
1976-
1977-
if (!TelemetryService.hasInstance()) {
1978-
TelemetryService.createInstance([])
1979-
}
1980-
1981-
mockApiConfig = {
1982-
apiProvider: "anthropic",
1983-
apiKey: "test-key",
1984-
}
1985-
1986-
mockProvider = {
1987-
context: {
1988-
globalStorageUri: { fsPath: "/test/storage" },
1989-
},
1990-
getState: vi.fn().mockResolvedValue({
1991-
apiConfiguration: mockApiConfig,
1992-
}),
1993-
say: vi.fn(),
1994-
postStateToWebview: vi.fn().mockResolvedValue(undefined),
1995-
postMessageToWebview: vi.fn().mockResolvedValue(undefined),
1996-
updateTaskHistory: vi.fn().mockResolvedValue(undefined),
1997-
log: vi.fn(),
1998-
}
1999-
})
2000-
2001-
it("should push tool_result to userMessageContent for native protocol with pending tool call ID", async () => {
2002-
// Create a task with a model that supports native tools
2003-
const task = new Task({
2004-
provider: mockProvider,
2005-
apiConfiguration: {
2006-
...mockApiConfig,
2007-
apiProvider: "anthropic",
2008-
toolProtocol: "native", // Explicitly set native protocol
2009-
},
2010-
task: "parent task",
2011-
startTask: false,
2012-
})
2013-
2014-
// Mock the API to return a native protocol model
2015-
vi.spyOn(task.api, "getModel").mockReturnValue({
2016-
id: "claude-3-5-sonnet-20241022",
2017-
info: {
2018-
contextWindow: 200000,
2019-
maxTokens: 8192,
2020-
supportsPromptCache: true,
2021-
supportsNativeTools: true,
2022-
defaultToolProtocol: "native",
2023-
} as ModelInfo,
2024-
})
2025-
2026-
// For native protocol, NewTaskTool does NOT push tool_result immediately.
2027-
// It only sets the pending tool call ID. The actual tool_result is pushed by completeSubtask.
2028-
task.pendingNewTaskToolCallId = "test-tool-call-id"
2029-
2030-
// Call completeSubtask
2031-
await task.completeSubtask("Subtask completed successfully")
2032-
2033-
// For native protocol, should push the actual tool_result with the subtask's result
2034-
expect(task.userMessageContent).toHaveLength(1)
2035-
expect(task.userMessageContent[0]).toEqual({
2036-
type: "tool_result",
2037-
tool_use_id: "test-tool-call-id",
2038-
content: "[new_task completed] Result: Subtask completed successfully",
2039-
})
2040-
2041-
// Should NOT have added a user message to apiConversationHistory
2042-
expect(task.apiConversationHistory).toHaveLength(0)
2043-
2044-
// pending tool call ID should be cleared
2045-
expect(task.pendingNewTaskToolCallId).toBeUndefined()
2046-
})
2047-
2048-
it("should add user message to apiConversationHistory for XML protocol", async () => {
2049-
// Create a task with a model that doesn't support native tools
2050-
const task = new Task({
2051-
provider: mockProvider,
2052-
apiConfiguration: {
2053-
...mockApiConfig,
2054-
apiProvider: "anthropic",
2055-
},
2056-
task: "parent task",
2057-
startTask: false,
2058-
})
2059-
2060-
// Mock the API to return an XML protocol model (no native tool support)
2061-
vi.spyOn(task.api, "getModel").mockReturnValue({
2062-
id: "claude-2",
2063-
info: {
2064-
contextWindow: 100000,
2065-
maxTokens: 4096,
2066-
supportsPromptCache: false,
2067-
supportsNativeTools: false,
2068-
} as ModelInfo,
2069-
})
2070-
2071-
// Call completeSubtask
2072-
await task.completeSubtask("Subtask completed successfully")
2073-
2074-
// For XML protocol, should add to apiConversationHistory
2075-
expect(task.apiConversationHistory).toHaveLength(1)
2076-
expect(task.apiConversationHistory[0]).toEqual(
2077-
expect.objectContaining({
2078-
role: "user",
2079-
content: [{ type: "text", text: "[new_task completed] Result: Subtask completed successfully" }],
2080-
}),
2081-
)
2082-
2083-
// Should NOT have added to userMessageContent
2084-
expect(task.userMessageContent).toHaveLength(0)
2085-
})
2086-
2087-
it("should set isPaused to false after completeSubtask", async () => {
2088-
const task = new Task({
2089-
provider: mockProvider,
2090-
apiConfiguration: mockApiConfig,
2091-
task: "parent task",
2092-
startTask: false,
2093-
})
2094-
2095-
// Mock the API to return an XML protocol model
2096-
vi.spyOn(task.api, "getModel").mockReturnValue({
2097-
id: "claude-2",
2098-
info: {
2099-
contextWindow: 100000,
2100-
maxTokens: 4096,
2101-
supportsPromptCache: false,
2102-
supportsNativeTools: false,
2103-
} as ModelInfo,
2104-
})
2105-
2106-
// Set isPaused to true (simulating waiting for subtask)
2107-
task.isPaused = true
2108-
task.childTaskId = "child-task-id"
2109-
2110-
// Call completeSubtask
2111-
await task.completeSubtask("Subtask completed")
2112-
2113-
// Should reset paused state
2114-
expect(task.isPaused).toBe(false)
2115-
expect(task.childTaskId).toBeUndefined()
2116-
})
2117-
})
21181969
})

0 commit comments

Comments
 (0)