Daita Logo

agent.db Context

Public inspection and debugging API attached to agents created by Agent.from_db().

#Overview

Every from_db() agent receives an agent.db context object:

python
agent = await Agent.from_db("postgresql://user:pass@host/db")
 
print(agent.db.schema)
print(agent.db.mode)
print(agent.db.summary)

Use this instead of reading private implementation attributes.

#Properties

PropertyDescription
agent.db.schemaDiscovered normalized schema
agent.db.pluginUnderlying database plugin
agent.db.modeSelected from_db mode
agent.db.driftSchema drift metadata, when detected
agent.db.memoryMemory plugin when memory is enabled
agent.db.memory_semanticsDB semantic memory adapter when memory is enabled
agent.db.lineageLineage plugin when lineage is enabled
agent.db.historyConversation history when history is enabled
agent.db.qualityDataQuality plugin when quality is enabled
agent.db.summaryCompact database summary
agent.db.suggested_questionsSuggested starter questions
agent.db.monitor_eventsLocal monitor event records

#Audit

python
await agent.run("Count orders by status")
 
print(agent.db.audit.entries)
print(agent.db.audit.last())
print(agent.db.audit.export_json(indent=2))

Audit entries are redacted and intended for debugging and observability.

#Findings

python
print(agent.db.findings.all)
print(agent.db.findings.open)
print(agent.db.findings.resolved)
print(agent.db.findings.last())

You can also add a finding from application code:

python
agent.db.findings.add({
    "title": "Orders table has stale data",
    "severity": "warning",
    "status": "open",
    "kind": "db_observation",
    "source": {"type": "manual"},
    "entity": {"table": "orders"},
    "observed": {"max_updated_at": "2026-05-15T00:00:00Z"},
})

#Register Monitors

python
agent.db.register_monitors([
    {
        "name": "Orders freshness",
        "type": "freshness",
        "severity": "warning",
        "entity": {"table": "orders"},
        "sql": "SELECT MAX(updated_at) FROM orders",
        "threshold": {"max_age_hours": 24},
    }
])

See Monitors & Findings for monitor details.

#describe()

from_db() agents also expose a DB-focused describe() method:

python
metadata = agent.describe()
 
print(metadata["kind"])
print(metadata["capabilities"])
print(metadata["db"]["query_policy"])

The response is compact and side-effect free. It is useful for logging, dashboards, and debugging.

#Stable vs Debug Fields

Prefer:

  • agent.db.*
  • agent.describe()
  • agent.tool_registry.tool_names

Avoid relying on private implementation attributes in application code. They may change as the runtime evolves.