feat(02-04): wire escalation into orchestrator pipeline

- Add escalation pre-check in _process_message: assistant mode for escalated threads
- Add escalation post-check after LLM response: calls escalate_to_human on rule match
- Load Slack bot token unconditionally (needed for escalation DM, not just placeholders)
- Add keyword-based conversation metadata detector (billing keywords, attempt counter)
- Add no-op audit logger stub (replaced by real AuditLogger from Plan 02 when available)
- Add escalation_assignee and natural_language_escalation fields to Agent model
- Add Alembic migration 003 for new Agent columns
This commit is contained in:
2026-03-23 14:53:45 -06:00
parent 420294b8fe
commit a025cadc44
3 changed files with 250 additions and 2 deletions

View File

@@ -113,6 +113,17 @@ class Agent(Base):
)
tool_assignments: Mapped[list[Any]] = mapped_column(JSON, nullable=False, default=list)
escalation_rules: Mapped[list[Any]] = mapped_column(JSON, nullable=False, default=list)
escalation_assignee: Mapped[str | None] = mapped_column(
Text,
nullable=True,
comment="Slack user ID of the human to DM on escalation (e.g. U0HUMANID)",
)
natural_language_escalation: Mapped[bool] = mapped_column(
Boolean,
nullable=False,
default=False,
comment="Whether natural language escalation phrases trigger handoff",
)
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),