DynamoDB for Team

Kern supports using DynamoDB as a storage backend for Teams using the DynamoDb class.

Usage

You need to provide aws_access_key_id and aws_secret_access_key parameters to the DynamoDb class.

1"""
2Run: `uv pip install openai newspaper4k lxml_html_clean kern-ai` to install the dependencies
3"""
4
5from typing import List
6
7from kern.agent import Agent
8from kern.db.dynamo import DynamoDb
9from kern.models.openai import OpenAIResponses
10from kern.team import Team
11from kern.tools.hackernews import HackerNewsTools
12from kern.tools.hackernews import HackerNewsTools
13from pydantic import BaseModel
14
15# Setup the DynamoDB database
16db = DynamoDb()
17
18class Article(BaseModel):
19 title: str
20 summary: str
21 reference_links: List[str]
22
23hn_researcher = Agent(
24 name="HackerNews Researcher",
25 model=OpenAIResponses(id="gpt-5.2"),
26 role="Gets top stories from hackernews.",
27 tools=[HackerNewsTools()],
28)
29
30web_searcher = Agent(
31 name="Web Searcher",
32 model=OpenAIResponses(id="gpt-5.2"),
33 role="Searches the web for information on a topic",
34 tools=[HackerNewsTools()],
35 add_datetime_to_context=True,
36)
37
38hn_team = Team(
39 name="HackerNews Team",
40 model=OpenAIResponses(id="gpt-5.2"),
41 members=[hn_researcher, web_searcher],
42 db=db,
43 instructions=[
44 "First, search hackernews for what the user is asking about.",
45 "Then, ask the web searcher to search for each story to get more information.",
46 "Finally, provide a thoughtful and engaging summary.",
47 ],
48 output_schema=Article,
49 markdown=True,
50 show_members_responses=True,
51)
52
53hn_team.print_response("Write an article about the top 2 stories on hackernews")

Params

ParameterTypeDefaultDescription
idOptional[str]-The ID of the database instance. UUID by default.
db_clientNone-The DynamoDB client to use.
region_nameoptional[str]-AWS region name.
aws_access_key_idoptional[str]-AWS access key ID.
aws_secret_access_keyoptional[str]-AWS secret access key.
session_tableoptional[str]-The name of the session table.
memory_tableoptional[str]-The name of the memory table.
metrics_tableoptional[str]-The name of the metrics table.
eval_tableoptional[str]-The name of the eval table.
knowledge_tableoptional[str]-The name of the knowledge table.
traces_tableoptional[str]-The name of the traces table.
spans_tableoptional[str]-The name of the spans table.