Skip to content

Commit 9bd3253

Browse files
committed
Change tool result to be string result instead of wrapper object
1 parent e24b851 commit 9bd3253

File tree

9 files changed

+20
-31
lines changed

9 files changed

+20
-31
lines changed

.agents/researcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Always end your response with the end_turn tool.\
5050
handleSteps: function* ({ agentState, prompt, params }) {
5151
yield {
5252
toolName: 'web_search',
53-
args: { query: prompt },
53+
args: { query: prompt ?? '', depth: 'standard' },
5454
}
5555
yield 'STEP_ALL'
5656
},

.agents/sonnet4-agent-builder.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ IMPORTANT: Always end your response with the end_turn tool when you have complet
127127
},
128128
}
129129

130-
if (configResult?.result) {
130+
if (configResult) {
131131
yield {
132132
toolName: 'write_file',
133133
args: {
134134
path: TEMPLATE_TYPES_PATH,
135135
instructions: 'Create agent template type definitions file',
136-
content: configResult.result,
136+
content: configResult,
137137
},
138138
}
139139
}
@@ -146,13 +146,13 @@ IMPORTANT: Always end your response with the end_turn tool when you have complet
146146
},
147147
}
148148

149-
if (toolsResult?.result) {
149+
if (toolsResult) {
150150
yield {
151151
toolName: 'write_file',
152152
args: {
153153
path: TOOL_DEFINITIONS_PATH,
154154
instructions: 'Create tools type file',
155-
content: toolsResult.result,
155+
content: toolsResult,
156156
},
157157
}
158158
}
@@ -169,8 +169,8 @@ IMPORTANT: Always end your response with the end_turn tool when you have complet
169169
},
170170
}
171171

172-
if (exampleAgentsResult?.result) {
173-
const exampleFiles = exampleAgentsResult.result
172+
if (exampleAgentsResult) {
173+
const exampleFiles = exampleAgentsResult
174174
.split('\n\n')
175175
.filter(Boolean)
176176

.agents/types/agent-config.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export interface AgentConfig {
151151
) => Generator<
152152
ToolCall | 'STEP' | 'STEP_ALL',
153153
void,
154-
{ agentState: AgentState; toolResult: ToolResult | undefined }
154+
{ agentState: AgentState; toolResult: string | undefined }
155155
>
156156
}
157157

backend/src/__tests__/run-programmatic-step.test.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ describe('runProgrammaticStep', () => {
378378

379379
it('should comprehensively test STEP_ALL functionality with multiple tools and state management', async () => {
380380
// Track all tool results and state changes for verification
381-
const toolResultsReceived: (ToolResult | undefined)[] = []
381+
const toolResultsReceived: (string | undefined)[] = []
382382
const stateSnapshots: AgentState[] = []
383383
let stepCount = 0
384384

@@ -573,10 +573,9 @@ describe('runProgrammaticStep', () => {
573573

574574
// Verify tool results were passed back to generator
575575
expect(toolResultsReceived).toHaveLength(7)
576-
expect(toolResultsReceived[0]?.toolName).toBe('read_files')
577-
expect(toolResultsReceived[0]?.result).toContain('authenticate')
578-
expect(toolResultsReceived[3]?.toolName).toBe('add_subgoal')
579-
expect(toolResultsReceived[6]?.toolName).toBe('set_output')
576+
expect(toolResultsReceived[0]).toContain('authenticate')
577+
expect(toolResultsReceived[3]).toContain('auth-analysis')
578+
expect(toolResultsReceived[6]).toContain('Output set successfully')
580579

581580
// Verify state management throughout execution
582581
expect(stateSnapshots).toHaveLength(7)
@@ -638,7 +637,7 @@ describe('runProgrammaticStep', () => {
638637

639638
it('should pass tool results back to generator', async () => {
640639
const toolResults: ToolResult[] = []
641-
let receivedToolResult: ToolResult | undefined
640+
let receivedToolResult: string | undefined
642641

643642
const mockGenerator = (function* () {
644643
const input1 = yield {
@@ -664,11 +663,7 @@ describe('runProgrammaticStep', () => {
664663

665664
await runProgrammaticStep(mockAgentState, mockParams)
666665

667-
expect(receivedToolResult).toEqual({
668-
toolName: 'read_files',
669-
toolCallId: 'test-id',
670-
result: 'file content',
671-
})
666+
expect(receivedToolResult).toEqual('file content')
672667
})
673668
})
674669

backend/src/run-programmatic-step.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export async function runProgrammaticStep(
148148
messages: agentState.messageHistory.map((msg) => ({ ...msg })),
149149
}
150150

151-
let toolResult: ToolResult | undefined
151+
let toolResult: string | undefined
152152
let endTurn = false
153153

154154
try {
@@ -232,7 +232,7 @@ export async function runProgrammaticStep(
232232
state.agentState.messageHistory = state.messages
233233

234234
// Get the latest tool result
235-
toolResult = toolResults[toolResults.length - 1]
235+
toolResult = toolResults[toolResults.length - 1]?.result
236236

237237
if (toolCall.toolName === 'end_turn') {
238238
endTurn = true

backend/src/templates/agents/file-explorer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const fileExplorer = {
5353
yield {
5454
toolName: 'set_output' as const,
5555
args: {
56-
results: spawnResult?.result,
56+
results: spawnResult,
5757
},
5858
}
5959
},

backend/src/templates/agents/thinking-base.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ export const thinkingBase = (
4545
],
4646
},
4747
}
48-
const { toolResult: thinkResult } = yield 'STEP'
49-
if (thinkResult?.toolName === 'end_turn') {
50-
break
51-
}
48+
yield 'STEP'
5249
}
5350
},
5451
})

common/src/types/agent-template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export type AgentTemplate<
3636
export type StepGenerator = Generator<
3737
Omit<ToolCall, 'toolCallId'> | 'STEP' | 'STEP_ALL', // Generic tool call type
3838
void,
39-
{ agentState: AgentState; toolResult: ToolResult | undefined }
39+
{ agentState: AgentState; toolResult: string | undefined }
4040
>
4141

4242
export type StepHandler<

common/src/util/types/agent-config.d.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@ export interface AgentConfig {
139139
* ],
140140
* },
141141
* }
142-
* const { toolResult: thinkResult } = yield 'STEP'
143-
* if (thinkResult?.toolName === 'end_turn') {
144-
* break
145-
* }
142+
* yield 'STEP'
146143
* }
147144
* }
148145
*/

0 commit comments

Comments
 (0)