Skip to content

test: add structured output integration tests#588

Open
jsamuel1 wants to merge 3 commits intostrands-agents:mainfrom
jsamuel1:feat/structured-output-integ-tests
Open

test: add structured output integration tests#588
jsamuel1 wants to merge 3 commits intostrands-agents:mainfrom
jsamuel1:feat/structured-output-integ-tests

Conversation

@jsamuel1
Copy link
Copy Markdown
Contributor

@jsamuel1 jsamuel1 commented Mar 1, 2026

Description

Add integration tests for structured output with Zod schemas, validating the feature works end-to-end with real model providers.

Changes

  • Test typed result matching Zod schema via agent.invoke()
  • Test structured output via streaming with agent.stream()
  • Validates schema fields (string, number) and content correctness

Testing

  • 2 new integration tests added to test/integ/agent.test.ts
  • All existing tests pass

@jsamuel1 jsamuel1 force-pushed the feat/structured-output-integ-tests branch from 34d8a8f to ce99923 Compare March 3, 2026 07:19
@jsamuel1 jsamuel1 marked this pull request as ready for review March 3, 2026 07:25
jsamuel1 added a commit to jsamuel1/sdk-typescript that referenced this pull request Mar 3, 2026
Combines the following feature branches:
- feat/summarizing-conversation-manager (PR strands-agents#524)
- feat/structured-output-integ-tests (PR strands-agents#588)
- feat/interrupt-system (PR strands-agents#586)
- feat/swarm-multi-agent (PR strands-agents#587)
- feat/graph-multi-agent (PR strands-agents#594)

All 1277 unit tests pass. No type errors.
@jsamuel1 jsamuel1 force-pushed the feat/structured-output-integ-tests branch from ce99923 to ced227a Compare March 9, 2026 20:37
@jsamuel1 jsamuel1 force-pushed the feat/structured-output-integ-tests branch from ced227a to 72da482 Compare March 18, 2026 23:25
Add integration tests for structured output with Zod schemas:

- Test typed result matching zod schema via invoke()
- Test structured output via streaming with stream()
- Validates schema fields (string, number) and content correctness
@jsamuel1 jsamuel1 force-pushed the feat/structured-output-integ-tests branch from 72da482 to 1eaf4e2 Compare March 22, 2026 07:44
await collectGenerator(agent.stream('What was the result?'))
})

describe.skipIf(!supports.tools)('Structured Output', () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an invoke structured output test above on line 508. It technically tests the stream path as well. It wouldn't hurt to have a stream test but if so, could you place it under the existing describe block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — moved both tests into the existing describe('Structured Output') block alongside the validated output test.

Consolidate the two separate Structured Output describe blocks
into one per reviewer feedback. The streaming and typed schema
tests now live alongside the existing validated output test.

---
Prompt: Review PR comments and address feedback
expect(result.structuredOutput).toStrictEqual({ answer: 4 })
})

it('returns typed result matching zod schema', async () => {
Copy link
Copy Markdown
Member

@pgrayy pgrayy Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a test for the invoke case above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — removed the duplicate invoke test. Only the streaming test remains as the new addition.

The existing 'returns validated structured output' test already
covers the invoke path. Keep only the streaming test as the new
addition per reviewer feedback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants