Memex Admin

Backend: Pydantic Agent Observability

Repository: mem-labs/mem

activeUpdated Feb 19, 2026, 8:25 PM

Policy ID js776qd0n88p1m6v85f4pgkzqh81dsra

Pydantic AI agent creation/execution must include observability signals.

Rationale:
- Named agents and span context are required for traceability in production diagnostics.

Scope:
- PR review policy for backend runtime code under `domains/python/backend/app/src/**` (excluding tests) that constructs or executes `pydantic_ai.Agent`.

Trigger A:
- New or changed `Agent(` construction.

Trigger B:
- New or changed agent execution calls (`run`, `run_sync`, `run_stream`, `iter`).

Approval checks:
1) Trigger A: each agent construction includes non-empty `name=`.
2) Trigger B: execution occurs inside a `logfire.span(...)` in the same logical execution path (same function or immediate wrapper helper).
3) Trigger B: span includes at least one stable correlation identifier keyword argument (`space_account_id`, `session_id`, `user_id`, or `note_id`).

Evidence:
- Diff shows `name=` on agent construction and span-wrapped execution path with identifier attributes.

Decision:
- Return NOT APPROVED when Trigger A or Trigger B is met and required observability signals are missing.