Skip to content

Conversation

@afarntrog
Copy link
Contributor

Issue #, if available:
#254

Description of changes:

  • Add OpenAI-format message converter for AgentCore Memory, enabling Strands SessionMessages (Bedrock Converse format) to be stored and retrieved as
    OpenAI-format payloads in STM events. Handles text messages, tool calls (tool_calls), tool results (tool role), and system messages with bidirectional
    conversion.
  • Extract converters into a converters subpackage under memory/integrations/strands/, introducing a MemoryConverter protocol that both BedrockConverseConverter
    and OpenAIConverseConverter implement. Shared logic (exceeds_conversational_limit, CONVERSATIONAL_MAX_SIZE) is centralized in protocol.py.
  • Make the converter injectable on AgentCoreMemorySessionManager via a new converter parameter (defaults to BedrockConverseConverter), allowing callers to plug
    in OpenAIConverseConverter or any custom implementation that satisfies the MemoryConverter protocol.
  • Rename AgentCoreMemoryConverter to BedrockConverseConverter for clarity, and update all references.
  • Add comprehensive tests: 504-line test suite for OpenAIConverseConverter covering message-to-payload, events-to-messages, round-trips, edge cases, and error
    handling. Add 143 lines of tests for the injectable converter integration on the session manager (default/custom converter, blob fallback, empty payloads).

Test plan

  • Run pytest tests/bedrock_agentcore/memory/integrations/strands/test_openai_converter.py -- all new OpenAI converter tests pass
  • Run pytest tests/bedrock_agentcore/memory/integrations/strands/test_bedrock_converter.py -- existing Bedrock converter tests pass with renamed class
  • Run pytest tests/bedrock_agentcore/memory/integrations/strands/test_agentcore_memory_session_manager.py -- session manager tests pass, including new
    TestInjectableConverter class

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Restructure strands integration by moving converters into a dedicated
`converters/` subpackage. Rename `AgentCoreMemoryConverter` to
`BedrockConverseConverter`, add `OpenAIConverseConverter` for OpenAI
format support, and introduce a `MemoryConverter` protocol to define
a common interface. Update `StrandsMemoryHook` to accept any converter
implementing the protocol, defaulting to `BedrockConverseConverter`.
- Carry over `status` field from Bedrock toolResult when converting to
  OpenAI format, and restore it when converting back to Bedrock format
- Refactor _openai_to_bedrock tool response construction for clarity
- Change fallback content from None to empty string for non-tool messages
- Add round-trip test assertion for status preservation
@afarntrog afarntrog requested a review from a team February 9, 2026 19:34
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.

1 participant