Skip to content

Commit 24aacee

Browse files
committed
Align agent validation tests with structured_output rules
1 parent 2c98be4 commit 24aacee

File tree

3 files changed

+8
-28
lines changed

3 files changed

+8
-28
lines changed

common/src/__tests__/agent-validation.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ describe('Agent Validation', () => {
750750
expect(typeof result.templates['test-agent'].handleSteps).toBe('string')
751751
})
752752

753-
test('should require set_output tool for handleSteps with json output mode', () => {
753+
test('allows handleSteps with structured_output without set_output (LLM handles output)', () => {
754754
const {
755755
DynamicAgentTemplateSchema,
756756
} = require('../types/dynamic-agent-template')
@@ -765,18 +765,14 @@ describe('Agent Validation', () => {
765765
systemPrompt: 'Test',
766766
instructionsPrompt: 'Test',
767767
stepPrompt: 'Test',
768-
toolNames: ['end_turn'], // Missing set_output
768+
toolNames: ['end_turn'], // set_output not required in current validation
769769
spawnableAgents: [],
770770
handleSteps:
771771
'function* () { yield { toolName: "set_output", input: {} } }',
772772
}
773773

774774
const result = DynamicAgentTemplateSchema.safeParse(agentConfig)
775-
expect(result.success).toBe(false)
776-
if (!result.success) {
777-
const errorMessage = result.error.issues[0]?.message || ''
778-
expect(errorMessage).toContain('set_output')
779-
}
775+
expect(result.success).toBe(true)
780776
})
781777

782778
// Note: The validation that rejected set_output without structured_output mode was

common/src/__tests__/dynamic-agent-template-schema.test.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -248,27 +248,15 @@ describe('DynamicAgentDefinitionSchema', () => {
248248
})
249249
})
250250

251-
it('should reject template with outputMode structured_output but missing set_output tool', () => {
251+
it('allows structured_output without set_output tool (LLM handles output)', () => {
252252
const template = {
253253
...validBaseTemplate,
254254
outputMode: 'structured_output' as const,
255255
toolNames: ['end_turn', 'read_files'], // Missing set_output
256256
}
257257

258258
const result = DynamicAgentTemplateSchema.safeParse(template)
259-
expect(result.success).toBe(false)
260-
if (!result.success) {
261-
// Find the specific error about set_output tool
262-
const setOutputError = result.error.issues.find((issue) =>
263-
issue.message.includes(
264-
"outputMode 'structured_output' requires the 'set_output' tool",
265-
),
266-
)
267-
expect(setOutputError).toBeDefined()
268-
expect(setOutputError?.message).toContain(
269-
"outputMode 'structured_output' requires the 'set_output' tool",
270-
)
271-
}
259+
expect(result.success).toBe(true)
272260
})
273261

274262
it('should accept template with outputMode structured_output and set_output tool', () => {

common/src/__tests__/handlesteps-parsing.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ describe('handleSteps Parsing Tests', () => {
143143
expect(typeof result.templates['test-agent'].handleSteps).toBe('string')
144144
})
145145

146-
test('should require set_output tool for handleSteps with json output mode', () => {
146+
test('allows handleSteps with structured_output without set_output (LLM handles output)', () => {
147147
const {
148148
DynamicAgentTemplateSchema,
149149
} = require('../types/dynamic-agent-template')
@@ -155,7 +155,7 @@ describe('handleSteps Parsing Tests', () => {
155155
spawnerPrompt: 'Testing handleSteps',
156156
model: 'claude-3-5-sonnet-20241022',
157157
outputMode: 'structured_output' as const,
158-
toolNames: ['end_turn'], // Missing set_output
158+
toolNames: ['end_turn'], // set_output not required in current validation
159159
spawnableAgents: [],
160160
systemPrompt: 'Test',
161161
instructionsPrompt: 'Test',
@@ -166,11 +166,7 @@ describe('handleSteps Parsing Tests', () => {
166166
}
167167

168168
const result = DynamicAgentTemplateSchema.safeParse(agentConfig)
169-
expect(result.success).toBe(false)
170-
if (!result.success) {
171-
const errorMessage = result.error.issues[0]?.message || ''
172-
expect(errorMessage).toContain('set_output')
173-
}
169+
expect(result.success).toBe(true)
174170
})
175171

176172
test('should validate that handleSteps is a generator function', async () => {

0 commit comments

Comments
 (0)