JsonDb class.
Usage
json_for_agent.py
"""Run `uv pip install openai` to install dependencies."""
from agno.agent import Agent
from agno.db.json import JsonDb
from agno.models.openai import OpenAIResponses
from agno.tools.hackernews import HackerNewsTools
# Setup the JSON database
db = JsonDb(db_path="tmp/json_db")
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
db=db,
tools=[HackerNewsTools()],
add_history_to_context=True,
)
agent.print_response("How many people live in Canada?")
agent.print_response("What is their national anthem called?")
Params
| Parameter | Type | Default | Description |
|---|---|---|---|
id | Optional[str] | - | The ID of the database instance. UUID by default. |
db_path | Optional[str] | - | Path to the directory where JSON files will be stored. |
session_table | Optional[str] | - | Name of the JSON file to store sessions (without .json extension). |
memory_table | Optional[str] | - | Name of the JSON file to store memories. |
metrics_table | Optional[str] | - | Name of the JSON file to store metrics. |
eval_table | Optional[str] | - | Name of the JSON file to store evaluation runs. |
knowledge_table | Optional[str] | - | Name of the JSON file to store knowledge content. |
traces_table | Optional[str] | - | Name of the JSON file to store traces. |
spans_table | Optional[str] | - | Name of the JSON file to store spans. |