AgentTemplate is NOT tenant-scoped — templates are global, readable by all authenticated users, no RLS needed
Deploy creates an independent Agent snapshot — changes to template do not affect deployed agents
GET /templates and GET /templates/{id} use get_portal_caller (not require_tenant_member) — no tenant_id path parameter available, any authenticated user can browse
AI transparency clause always appended — non-negotiable per Phase 1 architectural decision
Seed data uses conn.execute() with CAST(:col AS jsonb) pattern — consistent with Phase 2 asyncpg jsonb handling
duration
completed_date
tasks_completed
files_created_or_modified
7 minutes
2026-03-25
2
9
Phase 5 Plan 01: Agent Templates — Backend Foundation Summary
AgentTemplate ORM model, Alembic migration 007 with 7 seed templates, system prompt builder with mandatory AI transparency clause, template gallery API (list/detail/deploy), and comprehensive unit + integration test coverage.
Tasks Completed
#
Task
Commit
Files
1
AgentTemplate model, migration 007, system prompt builder, unit tests
AgentTemplate ORM Model (packages/shared/shared/models/tenant.py)
Added AgentTemplate class with fields: id (UUID PK), name, role, description, category, persona, system_prompt, model_preference, tool_assignments (JSON), escalation_rules (JSON), is_active, sort_order, created_at. NOT tenant-scoped — no tenant_id, no RLS.