Bedrock Agent not retaining the memory.

0

We have enabled the memory retention feature for our Amazon Bedrock Agent to retain session information.

Our guided chat flow takes the user through a 10-step journey. We want the Agent to resume the session from where the user left off if they return after some time. We planned to use the Bedrock Agent memory feature with the following settings:

  • session-idle-timeout: 60 seconds
  • memory-retention-period: 2 days
  • Model Claude-3-Sonnet

The Agent successfully remembers the previous chat and resumes the flow if the user returns within approximately 1 hour. However, when tested with a 12-hour gap, the Agent loses memory and restarts the flow from the beginning.

We are using the following code:

import boto3
from botocore.config import Config

region = 'us-east-1'
bedrock_agent_id = 'string'
bedrock_agent_alias_id = 'string'
session_id = 'code-generated id'
memory_id = 'code-generated id'

config = Config(read_timeout=1000)
agents_runtime_client = boto3.client(service_name="bedrock-agent-runtime", region_name=region, config=config)

response = agents_runtime_client.invoke_agent(
                agentId=bedrock_agent_id,
                agentAliasId=bedrock_agent_alias_id,
                sessionId=session_id,
                inputText=question,
                memoryId=memory_id
)

Additionally, I am trying to fetch the agent memory using a memory ID but am unable to retrieve any memory content:

def get_memory():
    response = agents_runtime_client.get_agent_memory(
        agentId=bedrock_agent_id,
        agentAliasId=bedrock_agent_alias_id,
        memoryId=memory_id,
        memoryType='SESSION_SUMMARY',
    )
    memory = ""
    for content in response['memoryContents']:
        if 'sessionSummary' in content:
            s = content['sessionSummary']
            memory += f"Session ID {s['sessionId']} from {s['sessionStartTime'].strftime(DATE_FORMAT)} to {s['sessionExpiryTime'].strftime(DATE_FORMAT)}\n"
            memory += s['summaryText'] + "\n"
    if memory == "":
        memory = "<no memory>"
    return memory

get_memory()

Is there something we are missing or configuring incorrectly? Any help to resolve these issues or any knowledge about this feature not working as expected is well appreciated. We understand that this feature is currently in preview, but the inconsistency with the basic guidance provided in the documentation is concerning.

1 Answer
0

Are you using Anthropic Claude 3 Sonnet v1 or Anthropic Claude 3 Haiku v1?
https://docs.aws.amazon.com/bedrock/latest/userguide/agents-memory.html

Supported models

You can only enable memory for Agents that are using the following models:

| Model name | Model Id| | -- | -- || Anthropic Claude 3 Sonnet v1 | anthropic.claude-3-sonnet-20240229-v1:0 Anthropic Claude 3 Haiku v1 | anthropic.claude-3-haiku-20240307-v1:0

AWS
EXPERT
answered a year ago
  • Hi, we are using Anthropic Claude 3 Sonnet v1.

  • This feature is only in Preview and not GA but perhaps logging a support case would be your best path forward.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions