Files
harness-sdk/tests_integ
Nick CleggandStrands Agent 6e7baf37e3 feat: Core Agent Integration Tests (Node.js) - Task 168.1 (#226)
* feat: add parameterized Agent integration tests for BedrockModel and OpenAIModel

- Create tests_integ/agent.test.ts with test.each parameterization
- Cover basic invocation, streaming, system prompts
- Test tool use and multi-turn conversations
- Test stop reasons (endTurn, toolUse, maxTokens)
- Test message history management
- Include Document and Image block media tests
- Use loadFixture helper for loading image fixtures
- All tests pass for BedrockModel (OpenAI skipped without API key)

Resolves: #193

* refactor: consolidate integration test helpers and reduce API calls

- Create tests_integ/__fixtures__/test-helpers.ts with loadFixture and hasOpenAIApiKey helpers
- Update bedrock.test.ts to use centralized loadFixture helper
- Update openai.test.ts to use centralized hasOpenAIApiKey helper
- Combine basic invocation and streaming tests into single test
- Consolidate multi-turn and message history tests
- Add comprehensive media blocks test with multiple media types in one call
- Reduce total API calls from 14 to 9 tests

Addresses feedback from PR #226

* refactor: improve test organization and OpenAI skip logic

- Rename hasOpenAIApiKey() to shouldSkipOpenAITests() for clarity
- Fix shouldSkipOpenAITests() to always check for actual API key presence
- Use describe.skipIf() instead of manual skip logic for better test visibility
- Include tool use in basic functionality test
- Remove redundant tests:
  - Remove separate tool execution flow test (covered in basic test)
  - Remove individual document and image block tests (covered by multi-media test)
  - Remove maxTokens error handling test
- Reduce total test count from 9 to 3 per provider while maintaining coverage

Addresses second round of feedback from PR #226

* refactor: improve test quality and CI behavior

- Update shouldSkipOpenAITests() to fail in CI when key is missing (not skip)
- Update basic functionality test to use calculator tool with 123 * 456
- Verify tool use in agent messages and result (56088)
- Remove initial state check from multi-turn test
- Initialize agent with messages array for media blocks test
- Use invoke() with text prompt instead of pushing to messages

Addresses third round of feedback from PR #226

* fix: wrap initial messages in Message constructor

- Import Message class from SDK
- Wrap messages array initialization in new Message() constructor
- Fixes 'Unknown ContentBlockData type' error in media blocks test
- Agent constructor processes Message instances directly without conversion

Fixes integration test failures in PR #226

* fix: add text block to initial message for Bedrock document requirement

- Import TextBlock from SDK
- Include TextBlock in initial message content array with document and image
- Bedrock requires text block when using documents
- Call invoke() without parameters since message is already initialized

Fixes ValidationException in media blocks test

---------

Co-authored-by: Strands Agent <217235299+strands-agent@users.noreply.github.com>
2025-11-25 01:32:42 +00:00
..
2025-11-11 13:14:42 -05:00