Copy
Ask AI
"""
04 Manually Add Culture
=============================
Manually add cultural knowledge to your Agents.
"""
from agno.agent import Agent
from agno.culture.manager import CultureManager
from agno.db.schemas.culture import CulturalKnowledge
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from rich.pretty import pprint
# ---------------------------------------------------------------------------
# Step 1. Initialize the database used for storing cultural knowledge
# ---------------------------------------------------------------------------
db = SqliteDb(db_file="tmp/demo.db")
# ---------------------------------------------------------------------------
# Step 2. Create the Culture Manager (no model needed for manual inserts)
# ---------------------------------------------------------------------------
culture_manager = CultureManager(db=db)
# ---------------------------------------------------------------------------
# Step 3. Manually add cultural knowledge
# ---------------------------------------------------------------------------
# Example: Response Format Standard (short and actionable)
response_format = CulturalKnowledge(
name="Response Format Standard (Agno)",
summary="Keep responses concise, scannable, and runnable-first where applicable.",
categories=["communication", "ux"],
content=(
"- Lead with the minimal runnable snippet or example when possible.\n"
"- Use numbered steps for procedures; keep each step testable.\n"
"- Prefer metric units and explicit defaults (ports, paths, versions).\n"
"- End with a short validation checklist."
),
notes=["Derived from repeated feedback favoring actionable answers."],
metadata={"source": "manual_seed", "version": 1},
)
# Persist the cultural knowledge
culture_manager.add_cultural_knowledge(response_format)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
# Optional: show what is stored
print("\n=== Cultural Knowledge (Manual Add) ===")
pprint(culture_manager.get_all_knowledge())
# ---------------------------------------------------------------------------
# Step 4. Initialize the Agent with cultural knowledge enabled
# ---------------------------------------------------------------------------
# The Agent will load shared cultural knowledge and include it in context.
agent = Agent(
db=db,
model=OpenAIResponses(id="gpt-5.2"),
add_culture_to_context=True, # adds culture into the prompt context
# update_cultural_knowledge=True, # uncomment to let the agent update culture after runs
)
# (Optional) A/B without culture for contrast:
# agent_no_culture = Agent(model=OpenAIResponses(id="gpt-5.2"))
# ---------------------------------------------------------------------------
# Step 5. Ask the Agent to generate a response that benefits from culture
# ---------------------------------------------------------------------------
print("\n=== With Culture ===\n")
agent.print_response(
"How do I set up a FastAPI service using Docker? ",
stream=True,
markdown=True,
)
# (Optional) Run without culture for contrast:
# print("\n=== Without Culture ===\n")
# agent_no_culture.print_response(
# "How do I set up a FastAPI service using Docker?",
# stream=True,
# markdown=True,
# )
Run the Example
Copy
Ask AI
# Clone and setup repo
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/02_agents/14_advanced
# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate
python 04_manually_add_culture.py