Skip to content

[Enhancement] Reduce create_agent() calls per invocation in AgentCoreMemorySessionManager #445

@emmanuelesperanca

Description

@emmanuelesperanca

Behavior observed:
AgentCoreMemorySessionManager.create_agent() is called N times per single
agent invocation (once per tool-use cycle in the Strands agent loop),
generating redundant memory write events and increasing latency

Evidence:
Session [X]: create_agent() called 3x for a single-turn interaction
with 1 tool call (KB search), generating events at t+0ms, t+366ms, t+5866ms
within the same traceId

Expected behavior:
create_agent() could be called once per invocation/session initialization? And not once per tool-use cycle?

Proposed solution options:

  1. Add a flag create_agent_per_turn: bool = False to AgentCoreMemoryConfig
  2. Deduplicate create_agent() calls within the same session_id + agent_id
    using an in-memory set in the session manager

Impact:

  • Extra memory write operations per invocation
  • Noise in observability traces
  • Increased latency for multi-tool invocations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions