DynamoDB for Team
Store team sessions and run history in DynamoDB with DynamoDb.
DynamoDb stores a Team's 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-***Pass a configured DynamoDB client as db_client. Otherwise, set the AWS_REGION, AWS_ACCESS_KEY_ID, and AWS_SECRET_ACCESS_KEY environment variables or pass region_name, aws_access_key_id, and aws_secret_access_key directly.
On first use, DynamoDb creates missing tables with provisioned capacity. The client or credentials must allow table creation and read/write operations.
Install dependencies:
uv pip install agno boto3 openai ddgsfrom typing import List
from agno.agent import Agent
from agno.db.dynamo import DynamoDb
from agno.models.openai import OpenAIResponses
from agno.team import Team
from agno.tools.hackernews import HackerNewsTools
from agno.tools.websearch import WebSearchTools
from pydantic import BaseModel
db = DynamoDb()
class Article(BaseModel):
title: str
summary: str
reference_links: List[str]
hn_researcher = Agent(
name="HackerNews Researcher",
model=OpenAIResponses(id="gpt-5.2"),
role="Gets top stories from HackerNews.",
tools=[HackerNewsTools()],
)
web_searcher = Agent(
name="Web Searcher",
model=OpenAIResponses(id="gpt-5.2"),
role="Searches the web for information on a topic",
tools=[WebSearchTools()],
add_datetime_to_context=True,
)
hn_team = Team(
name="HackerNews Team",
model=OpenAIResponses(id="gpt-5.2"),
members=[hn_researcher, web_searcher],
db=db,
instructions=[
"First, search HackerNews for what the user is asking about.",
"Then, ask the web searcher to search for each story to get more information.",
"Finally, provide a thoughtful and engaging summary.",
],
output_schema=Article,
markdown=True,
show_members_responses=True,
)
hn_team.print_response("Write an article about the top 2 stories on HackerNews")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. |
Run the Example
Save the code as dynamo_for_team.py, complete the prerequisites above, then run:
python dynamo_for_team.py