llama-index-integrations/memory/llama-index-memory-bedrock-agentcore/README.md
To install the required package, run:
%pip install llama-index-memory-bedrock-agentcore
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)
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,
)
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
)