Skip to content

Commit 06d1ec9

Browse files
committed
fix agent-runtime tests
1 parent ed81e9a commit 06d1ec9

File tree

3 files changed

+10
-49
lines changed

3 files changed

+10
-49
lines changed

packages/agent-runtime/src/__tests__/main-prompt.test.ts

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -195,48 +195,6 @@ describe('mainPrompt', () => {
195195
},
196196
}
197197

198-
it('should handle direct terminal command', async () => {
199-
const sessionState = getInitialSessionState(mockFileContext)
200-
const action = {
201-
type: 'prompt' as const,
202-
prompt: 'ls -la',
203-
sessionState,
204-
fingerprintId: 'test',
205-
costMode: 'max' as const,
206-
promptId: 'test',
207-
toolResults: [],
208-
}
209-
210-
const { sessionState: newSessionState, output } = await mainPrompt({
211-
...mainPromptBaseParams,
212-
action,
213-
})
214-
215-
// Verify that requestToolCall was called with the terminal command
216-
const requestToolCallSpy = mainPromptBaseParams.requestToolCall
217-
expect(requestToolCallSpy).toHaveBeenCalledTimes(1)
218-
expect(requestToolCallSpy).toHaveBeenCalledWith({
219-
userInputId: expect.any(String), // userInputId
220-
toolName: 'run_terminal_command',
221-
input: expect.objectContaining({
222-
command: 'ls -la',
223-
mode: 'user',
224-
process_type: 'SYNC',
225-
timeout_seconds: -1,
226-
}),
227-
})
228-
229-
// Verify that the output contains the expected structure
230-
expect(output.type).toBeDefined()
231-
232-
// Verify that a tool result was added to message history
233-
const toolResultMessages =
234-
newSessionState.mainAgentState.messageHistory.filter(
235-
(m) => m.role === 'tool',
236-
)
237-
expect(toolResultMessages.length).toBeGreaterThan(0)
238-
})
239-
240198
it('should handle write_file tool call', async () => {
241199
// Mock LLM to return a write_file tool call using getToolCallString
242200
const mockResponse =

packages/agent-runtime/src/__tests__/prompt-caching-subagents.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ describe('Prompt Caching for Subagents with inheritParentSystemPrompt', () => {
400400
// Verify both agents use the same system prompt
401401
expect(parentMessages[0].role).toBe('system')
402402
expect(childMessages[0].role).toBe('system')
403-
expect(childMessages[0].content).toBe(parentMessages[0].content)
403+
expect(childMessages[0].content).toEqual(parentMessages[0].content)
404404

405405
// This matching system prompt enables prompt caching:
406406
// Both agents will have the same system message at the start,

packages/agent-runtime/src/__tests__/spawn-agents-message-history.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,24 +167,27 @@ describe('Spawn Agents Message History', () => {
167167
(msg: any) => msg.role === 'system',
168168
)
169169
expect(systemMessages).toHaveLength(1)
170-
expect(systemMessages[0].content).toBe(
171-
'This is the parent system prompt that should be excluded',
172-
)
170+
expect(systemMessages[0].content).toEqual([
171+
{
172+
type: 'text',
173+
text: 'This is the parent system prompt that should be excluded',
174+
},
175+
])
173176

174177
// Verify user and assistant messages are included
175178
expect(
176179
capturedSubAgentState.messageHistory.find(
177-
(msg: any) => msg.content === 'Hello',
180+
(msg: any) => msg.content[0]?.text === 'Hello',
178181
),
179182
).toBeTruthy()
180183
expect(
181184
capturedSubAgentState.messageHistory.find(
182-
(msg: any) => msg.content === 'Hi there!',
185+
(msg: any) => msg.content[0]?.text === 'Hi there!',
183186
),
184187
).toBeTruthy()
185188
expect(
186189
capturedSubAgentState.messageHistory.find(
187-
(msg: any) => msg.content === 'How are you?',
190+
(msg: any) => msg.content[0]?.text === 'How are you?',
188191
),
189192
).toBeTruthy()
190193
})

0 commit comments

Comments
 (0)