DynamoDB
Store agent sessions and run history in DynamoDB with DynamoDb.
DynamoDb stores Agent sessions and run history in DynamoDB.
Usage
Start in a virtual environment and set the model key before running the example.
Set OpenAI Key
Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.
export OPENAI_API_KEY=sk-***Install the boto3 and openai packages:
uv pip install agno boto3 openaiPass a configured DynamoDB client as db_client, or set all three environment variables:
AWS_REGION: The AWS region to connect to.AWS_ACCESS_KEY_ID: Your AWS access key ID.AWS_SECRET_ACCESS_KEY: Your AWS secret access key.
On first use, DynamoDb creates missing tables with provisioned capacity. The client or credentials must allow table creation and read/write operations.
from agno.agent import Agent
from agno.db.dynamo import DynamoDb
db = DynamoDb()
agent = Agent(db=db)region_name, aws_access_key_id, and aws_secret_access_key accept the same values directly.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
id | Optional[str] | - | Database ID. Derived deterministically from explicit client or constructor region/key values when omitted. |
db_client | Optional[Any] | - | The DynamoDB client to use. |
region_name | Optional[str] | - | AWS region name. |
aws_access_key_id | Optional[str] | - | AWS access key ID. |
aws_secret_access_key | Optional[str] | - | AWS secret access key. |
session_table | Optional[str] | - | The name of the session table. |
runs_table | Optional[str] | None | Storage name for individual runs. Defaults to agno_runs, or <session_table>_runs when a custom session name is supplied. |
memory_table | Optional[str] | - | The name of the memory table. |
metrics_table | Optional[str] | - | The name of the metrics table. |
eval_table | Optional[str] | - | The name of the eval table. |
knowledge_table | Optional[str] | - | The name of the knowledge table. |
traces_table | Optional[str] | - | The name of the traces table. |
spans_table | Optional[str] | - | The name of the spans table. |