Skip to main content

llama-index memory bedrock agentcore integration

Project description

LlamaIndex Memory Integration: Bedrock AgentCore

Installation

To install the required package, run:

%pip install llama-index-memory-bedrock-agentcore

Bedrock AgentCore Setup Pre-Requisites

  1. AWS account with Bedrock AgentCore access
  2. Configured AWS credentials (boto3)
  3. Created memory resource in AWS Bedrock AgentCore
  4. Required IAM permissions:
    1. bedrock-agentcore:CreateEvent
    2. bedrock-agentcore:ListEvents
    3. bedrock-agentcore:RetrieveMemories

Sample Usage

  1. Create an instance of AgentCoreMemoryContext to setup the memory resources that you will need for building an agent.
    1. Actor id → This is a required field and it is the identifier of the actor (could be an agent or the end-user).
    2. Memory id → This is a required field and it is the identifier of the memory store.
    3. Session id → This is a required field and it is the unique identifier of a particular conversation.
    4. Namespace → This is an optional field and it is used to determine how to extract long term memories. By default it will use “/” as the namespace.
    5. Memory strategy id → This is an optional field and it is the identifier for a memory strategy.
context = AgentCoreMemoryContext(
    actor_id="<INSERT_HERE>",
    memory_id="<INSERT_HERE>",
    session_id="<INSERT_HERE>",
    namespace="<INSERT_HERE>",
    memory_strategy_id="<INSERT_HERE>",
)
agentcore_memory = AgentCoreMemory(context=context)
  1. This is an example of how to create a FunctionAgent in LlamaIndex. This sample adds a tool & the Claude Sonnet 4 LLM to the agent’s initialization.

If you would like to use this tool, the run the following command

%pip install llama-index-tools-yahoo-finance
from llama_index.llms.bedrock_converse import BedrockConverse
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.tools.yahoo_finance import YahooFinanceToolSpec

llm = BedrockConverse(model="us.anthropic.claude-sonnet-4-20250514-v1:0")

finance_tool_spec = YahooFinanceToolSpec()
agent = FunctionAgent(
    tools=finance_tool_spec.to_tool_list(),
    llm=llm,
)

Here's a simpler example that doesn't utilize a third party tool

from llama_index.core.tools import FunctionTool
from llama_index.core.agent.workflow import FunctionAgent


def call_fn(name: str):
    """Call the provided name.
    Args:
        name: str (Name of the person)
    """
    print(f"Calling... {name}")


def email_fn(name: str):
    """Email the provided name.
    Args:
        name: str (Name of the person)
    """
    print(f"Emailing... {name}")


call_tool = FunctionTool.from_defaults(fn=call_fn)
email_tool = FunctionTool.from_defaults(fn=email_fn)

agent = FunctionAgent(
    tools=[call_tool, email_tool],
    llm=llm,
)
  1. Invoke the agent to start conversations

This sample will invoke the tool and store the events in AgentCore Memory

response = await agent.run(
    "What is the stock price of Amazon?", memory=agentcore_memory
)

After events are stored, you can then prompt the agent to answer any queries based on the memory records

response = await agent.run(
    "What stock prices have I asked for?", memory=agentcore_memory
)

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_memory_bedrock_agentcore-0.1.1.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_memory_bedrock_agentcore-0.1.1.tar.gz.

File metadata

  • Download URL: llama_index_memory_bedrock_agentcore-0.1.1.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_memory_bedrock_agentcore-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cd79b1e1bb9b2a7baf430b88ad324f82da71d99c7ba55acc560f5a2b9190f1be
MD5 f701b0e765486a180f8dcaf45406fe78
BLAKE2b-256 a220dee0ae8dea039f82c8a7f4802f7623fe0d304250f08af1a4f5f6c63860eb

See more details on using hashes here.

File details

Details for the file llama_index_memory_bedrock_agentcore-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: llama_index_memory_bedrock_agentcore-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llama_index_memory_bedrock_agentcore-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4e382c08f182fb06231bab5b0cd342d3e9647aed8be73e269751e93f75f7440a
MD5 25566821fe5bb7ad403ddb3e9c187046
BLAKE2b-256 3f1e9f336e516c5d64b9d117ce0902ddc7f64119e840da846c621611a7b8fe24

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page