JsonDb class.
Usage
Install theopenai and ddgs packages:
uv pip install openai ddgs
json_for_agent.py
from agno.agent import Agent
from agno.db.json import JsonDb
from agno.models.openai import OpenAIChat
from agno.tools.websearch import WebSearchTools
# Setup the JSON database
db = JsonDb(db_path="tmp/json_db")
agent = Agent(
model=OpenAIChat(id="gpt-5.2"),
db=db,
session_id="session_storage",
tools=[WebSearchTools()],
add_history_to_context=True,
num_history_runs=3,
)
agent.print_response("How many people live in France?")
agent.print_response("What is their national anthem called?")
agent.print_response("What have we been talking about?")
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. |
culture_table | Optional[str] | - | Name of the JSON file to store cultural knowledge. |
traces_table | Optional[str] | - | Name of the JSON file to store traces. |
spans_table | Optional[str] | - | Name of the JSON file to store spans. |