Skip to content

AgentCoreMemorySessionManager Requires access to all actor_id prefixes "agent_*" and "session_*" #196

@ian-norris-ncino

Description

@ian-norris-ncino

Describe the bug
AgentCore Memory session manager uses prefixed actor IDs instead of configured actor_id for certain operations, causing IAM access denied errors when using restrictive policies based on the provided actor_id.

To Reproduce
Steps to reproduce the behavior:

  1. Configure AgentCoreMemorySessionManager with a specific actor_id (e.g., "tenant123/user456")
  2. Create IAM policy that only allows memory operations for that exact actor_id using bedrock-agentcore:actorId condition
  3. Initialize the session manager in your application
  4. Attempt to create or read session/agent data
  5. See AccessDeniedException because the library internally uses "session_" and "agent_" prefixed actor IDs

Expected behavior
The session manager should use the configured actor_id for all memory operations, or clearly document that additional actor_id patterns need to be allowed in IAM policies when using bedrock-agentcore:actorId conditions.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
The AgentCoreMemorySessionManager class internally uses three different actor_id patterns:

  1. Configured actor_id (e.g., "tenant123/user456") - used for message operations
  2. "session_" prefix (e.g., "session_abc123") - used in _get_full_session_id() for session operations
  3. "agent_" prefix (e.g., "agent_claude") - used in _get_full_agent_id() for agent operations

Lines of interest in session_manager.py:

  • Line 136: return f"{SESSION_PREFIX}{session_id}"
  • Line 152: return f"{AGENT_PREFIX}{agent_id}"
  • Line 181: Uses session-prefixed actor_id for create_session()
  • Line 252: Uses agent-prefixed actor_id for create_agent()
  • Line 364: Uses configured actor_id for create_message()

IAM Condition Key Behavior
The bedrock-agentcore:actorId condition key compares against the actual actor_id sent in each API call:

  • When the library calls create_session(), it sends actorId: "session_<session_id>"
  • When the library calls create_agent(), it sends actorId: "agent_<agent_id>"
  • When the library calls create_message(), it sends actorId: "<your_configured_actor_id>"

IAM policies that only allow your configured actor_id will deny the prefixed calls, causing failures during session manager initialization and agent operations.

Workaround
Use IAM condition with ForAnyValue:StringLike to allow multiple actor_id patterns:

  {
    "Condition": {
      "ForAnyValue:StringLike": {
        "bedrock-agentcore:actorId": [
          "session_*",
          "agent_*",
          "your-configured-actor-id"
        ]
      }
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions