Skip to main content
A data agent that only runs in a notebook helps one analyst. Behind an API, it answers questions from a Slack channel, a BI dashboard’s natural-language box, or an “explain this metric” widget in your product. AgentOS turns the agent into that API. Start PgVector on port 5532 before running this example.
data_agent.py
Run it with python data_agent.py. The app="data_agent:app" import string has to match the module name. Every surface then calls the same endpoint:

Surfaces a data agent lives on

The serving model is identical to a product agent. The difference is what the agent does, not how it is served. user_id and session_id select the conversation history for a run.
This example leaves AgentOS authorization disabled. Callers can supply their own user and session identifiers. Enable AgentOS authorization before network exposure, and connect SQLTools with a database role that enforces read-only access.

Shared learnings, separate sessions

A data agent’s value compounds when corrections are shared across the team. Conversation threads stay scoped by user_id and session_id. learning=True only enables the per-user profile and memory stores, so to share what the agent learns, pass a knowledge base to LearningMachine instead. That enables the Learned Knowledge store, whose namespace defaults to "global", so a fix triggered by one analyst’s question helps everyone.
The store runs in AGENTIC mode: the model decides when to call save_learning and search_learnings. To keep learnings inside one team or tenant, set namespace on LearningMachine.

Next steps

Developer Resources