Skip to content

[BUG] AttributeError in AgentCoreMemorySessionManager when created_message is None #215

@Sami-Tanquary

Description

@Sami-Tanquary

Describe the bug
When using Strands agents with tool calls on the AgentCore runtime, applying the upstream OpenTelemetry fix for Bedrock ConverseStream responses (PR #3990) consistently exposes a failure in the AgentCore Memory Strands session manager during message persistence.

Specifically, AgentCoreMemorySessionManager.append_message assumes the memory “create message/event” call always returns a dict, and crashes when it returns None:

created_message.get("eventId")
# AttributeError: 'NoneType' object has no attribute 'get'

This occurs when the session manager hook attempts to persist Strands message events generated during tool-use flows.

To Reproduce
Steps to reproduce the behavior:

  1. Deploy a Strands agent configured to use AgentCore Memory on the AgentCore runtime.

  2. Enable tool calling on the agent.

  3. Apply the upstream OpenTelemetry Bedrock ConverseStream guard (PR #3990) to avoid the KeyError: 'output' crash (the runtime currently injects an AWS OpenTelemetry distro that predates this fix).

  4. Invoke a tool during a normal agent turn (toolUse → toolResult).

  5. Observe the agent invocation fail with:

AttributeError: 'NoneType' object has no attribute 'get'
  at bedrock_agentcore/memory/integrations/strands/session_manager.py:488

Expected behavior

  • Applying the upstream OpenTelemetry fix should allow execution to proceed normally.

  • If a memory persistence call fails or returns an empty response, the AgentCore Memory session manager should handle it gracefully (or surface a clear error), rather than crashing the agent event loop.

  • Tool-use flows should not cause unhandled exceptions during memory message persistence.

Screenshots
N/A (stack trace and logs available).

Desktop (please complete the following information):
OS: Linux (AgentCore managed runtime)
Runtime: AWS Bedrock AgentCore
Python: 3.13
Strands Agents: 1.21.0
bedrock-agentcore: 1.2.0

Additional context

  • The AgentCore runtime injects an AWS OpenTelemetry distro (telemetry.auto.version: 0.12.2-aws) that does not yet include the upstream OpenTelemetry fix for Bedrock ConverseStream (PR #3990).

  • Applying that fix via monkey patch unblocks execution but consistently exposes this separate failure in the AgentCore Memory Strands integration.

  • The failure occurs when the session manager hook attempts to persist Strands message events produced during tool-use flows; the persistence call returns None, which is not currently guarded against.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions