Skip to content

Commit 384e4df

Browse files
committed
Fix tests
1 parent c44878f commit 384e4df

File tree

4 files changed

+39
-62
lines changed

4 files changed

+39
-62
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,10 @@ 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+
// Note: The validation that required set_output tool for structured_output mode was
754+
// intentionally disabled to allow handleSteps to use set_output while the LLM does not
755+
// have access to the set_output tool.
756+
test('should allow structured_output mode without set_output tool in toolNames', () => {
754757
const {
755758
DynamicAgentTemplateSchema,
756759
} = require('../types/dynamic-agent-template')
@@ -765,18 +768,14 @@ describe('Agent Validation', () => {
765768
systemPrompt: 'Test',
766769
instructionsPrompt: 'Test',
767770
stepPrompt: 'Test',
768-
toolNames: ['end_turn'], // Missing set_output
771+
toolNames: ['end_turn'], // Missing set_output - now allowed
769772
spawnableAgents: [],
770773
handleSteps:
771774
'function* () { yield { toolName: "set_output", input: {} } }',
772775
}
773776

774777
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-
}
778+
expect(result.success).toBe(true)
780779
})
781780

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

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

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

251-
it('should reject template with outputMode structured_output but missing set_output tool', () => {
251+
// Note: The validation that required set_output tool for structured_output mode was
252+
// intentionally disabled to allow handleSteps to use set_output while the LLM does not
253+
// have access to the set_output tool.
254+
it('should allow template with outputMode structured_output without set_output tool', () => {
252255
const template = {
253256
...validBaseTemplate,
254257
outputMode: 'structured_output' as const,
255-
toolNames: ['end_turn', 'read_files'], // Missing set_output
258+
toolNames: ['end_turn', 'read_files'], // Missing set_output - now allowed
256259
}
257260

258261
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-
}
262+
expect(result.success).toBe(true)
272263
})
273264

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

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ 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+
// Note: The validation that required set_output tool for structured_output mode was
147+
// intentionally disabled to allow handleSteps to use set_output while the LLM does not
148+
// have access to the set_output tool.
149+
test('should allow structured_output mode without set_output tool in toolNames', () => {
147150
const {
148151
DynamicAgentTemplateSchema,
149152
} = require('../types/dynamic-agent-template')
@@ -155,7 +158,7 @@ describe('handleSteps Parsing Tests', () => {
155158
spawnerPrompt: 'Testing handleSteps',
156159
model: 'claude-3-5-sonnet-20241022',
157160
outputMode: 'structured_output' as const,
158-
toolNames: ['end_turn'], // Missing set_output
161+
toolNames: ['end_turn'], // Missing set_output - now allowed
159162
spawnableAgents: [],
160163
systemPrompt: 'Test',
161164
instructionsPrompt: 'Test',
@@ -166,11 +169,7 @@ describe('handleSteps Parsing Tests', () => {
166169
}
167170

168171
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-
}
172+
expect(result.success).toBe(true)
174173
})
175174

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

sdk/src/__tests__/validate-agents.test.ts

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -299,30 +299,6 @@ describe('validateAgents', () => {
299299
expect(result.errorCount).toBeGreaterThan(0)
300300
})
301301

302-
it('should reject structured_output without set_output tool', async () => {
303-
const agents: AgentDefinition[] = [
304-
{
305-
id: 'missing-set-output',
306-
displayName: 'Missing Set Output Tool',
307-
model: 'anthropic/claude-sonnet-4',
308-
outputMode: 'structured_output',
309-
toolNames: ['read_files'], // Missing set_output
310-
outputSchema: {
311-
type: 'object',
312-
properties: {
313-
result: { type: 'string' },
314-
},
315-
required: ['result'],
316-
},
317-
},
318-
]
319-
320-
const result = await validateAgents(agents)
321-
322-
expect(result.success).toBe(false)
323-
expect(result.errorCount).toBeGreaterThan(0)
324-
})
325-
326302
it('should reject spawnableAgents without spawn_agents tool', async () => {
327303
const agents: AgentDefinition[] = [
328304
{
@@ -491,11 +467,14 @@ describe('validateAgents', () => {
491467

492468
it('should handle very large number of agents', async () => {
493469
// Create 100 agents
494-
const agents: AgentDefinition[] = Array.from({ length: 100 }, (_, i) => ({
495-
id: `agent-${i}`,
496-
displayName: `Agent ${i}`,
497-
model: 'anthropic/claude-sonnet-4',
498-
}))
470+
const agents: AgentDefinition[] = Array.from(
471+
{ length: 100 },
472+
(_, i) => ({
473+
id: `agent-${i}`,
474+
displayName: `Agent ${i}`,
475+
model: 'anthropic/claude-sonnet-4',
476+
}),
477+
)
499478

500479
const result = await validateAgents(agents)
501480

@@ -546,7 +525,9 @@ describe('validateAgents', () => {
546525
const result = await validateAgents(agents)
547526

548527
expect(result.success).toBe(false)
549-
expect(result.validationErrors[0].message).toContain('lowercase letters, numbers, and hyphens')
528+
expect(result.validationErrors[0].message).toContain(
529+
'lowercase letters, numbers, and hyphens',
530+
)
550531
})
551532

552533
it('should handle deeply nested input schemas', async () => {
@@ -752,7 +733,10 @@ describe('validateAgents', () => {
752733
json: async () => ({
753734
success: false,
754735
validationErrors: [
755-
{ filePath: 'bad-agent', message: 'Agent "bad-agent": Invalid configuration' },
736+
{
737+
filePath: 'bad-agent',
738+
message: 'Agent "bad-agent": Invalid configuration',
739+
},
756740
],
757741
errorCount: 1,
758742
}),
@@ -765,7 +749,9 @@ describe('validateAgents', () => {
765749

766750
expect(result.success).toBe(false)
767751
expect(result.errorCount).toBe(1)
768-
expect(result.validationErrors[0].message).toContain('Invalid configuration')
752+
expect(result.validationErrors[0].message).toContain(
753+
'Invalid configuration',
754+
)
769755
})
770756

771757
it('should handle HTTP errors from API', async () => {
@@ -792,7 +778,9 @@ describe('validateAgents', () => {
792778
expect(result.success).toBe(false)
793779
expect(result.errorCount).toBe(1)
794780
expect(result.validationErrors[0].id).toBe('network_error')
795-
expect(result.validationErrors[0].message).toContain('Server error occurred')
781+
expect(result.validationErrors[0].message).toContain(
782+
'Server error occurred',
783+
)
796784
})
797785

798786
it('should handle network failures', async () => {

0 commit comments

Comments
 (0)