Skip to content

Strands templates set relevance_score=0.5, which filters out every long-term memory on a basic recall question #2706

Closed

Description

@DennisTraub

Description

The Python Strands templates set relevance_score=0.5 on every RetrievalConfig in memory/session.py. AgentCore Memory returns scores between 0.34 and 0.37 for a basic recall question against the facts it extracted. The Strands session manager drops every record below the threshold, so the agent gets no memories and answers as if it never heard the facts. The invoke returns status 200 and no error.

The value is in these templates:

  • src/assets/templates/agent-python-strands/memory/session.py lines 17 to 20
  • src/assets/templates/a2a-python-strands/memory/session.py
  • src/assets/templates/agui-python-strands/memory/session.py
  • src/assets/templates/export-harness-python/memory/session.py, as the fallback when memoryRetrievalRelevanceScore is not set

The RetrievalConfig default in bedrock-agentcore 1.25.0 is 0.2. The filter is in bedrock_agentcore/memory/integrations/strands/session_manager.py line 886, which keeps only records whose score is at least relevance_score.

Steps to Reproduce

  1. agentcore create --name Repro4 --template agent-python-strands
  2. agentcore deploy
  3. agentcore invoke --runtime agent --session-id <session A> --payload '{"prompt":"My name is Mike and I live in Australia. I like drinking English Breakfast tea.","actorId":"mike"}'
  4. Wait until aws bedrock-agentcore list-memory-records --memory-id <id> --namespace /users/mike/facts lists the extracted facts. In my run this took about two minutes and produced three records.
  5. aws bedrock-agentcore retrieve-memory-records --memory-id <id> --namespace /users/mike/facts --search-criteria '{"searchQuery":"What is my name?","topK":3}'
  6. agentcore invoke --runtime agent --session-id <session B> --payload '{"prompt":"What is my name?","actorId":"mike"}'
  7. Change relevance_score=0.5 to relevance_score=0.2 in app/agent/memory/session.py, run agentcore deploy, and repeat step 6 with a new session ID.

Expected Behavior

In step 6 the agent answers with the name it was told in step 3.

Actual Behavior

Step 5 returns these scores:

  • 0.36264706 for "Mike lives in Australia."
  • 0.35874188 for "The user's name is Mike."
  • 0.343668 for "Mike likes drinking English Breakfast tea."

In step 6 the agent answers "I don't know your name. You haven't told me, and I can't see any personal details about you."

In step 7, with only the threshold changed, the agent answers "Your name is Mike. You also told me you live in Australia and like English Breakfast tea."

CLI Version

1.0.0

Operating System

macOS

Additional Context

Region us-east-1. Runtime PYTHON_3_14. bedrock-agentcore 1.25.0, as installed by the generated project. Memory strategies are the template defaults (SEMANTIC, USER_PREFERENCE, SUMMARIZATION, EPISODIC).

Removing relevance_score from the four RetrievalConfig calls would fall back to the SDK default of 0.2. In this run 0.2 kept all three facts.

Activity

  1. self-assigned this
    on Oct 26, 2026
  2. notgitika commented on Oct 26, 2026

    @notgitika
    Contributor

    Thank you for bringing this up! We are coordinating with the memory team to decide any changes needed in the template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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