Files
konstruct/migrations/versions/003_escalation_fields.py
Adolfo Delorenzo a025cadc44 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
2026-03-23 14:53:45 -06:00

57 lines
1.6 KiB
Python

"""Phase 2 Plan 04: Add escalation_assignee and natural_language_escalation to agents
Revision ID: 003
Revises: 002
Create Date: 2026-03-23
These columns support the human escalation/handoff system:
- escalation_assignee: Slack user ID of the human to DM when escalation triggers
- natural_language_escalation: tenant-level flag enabling NL phrase detection
Both are nullable/defaulted so existing agent rows are unaffected.
"""
from __future__ import annotations
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "003"
down_revision: Union[str, None] = "002"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# Add escalation_assignee column — nullable TEXT
op.add_column(
"agents",
sa.Column(
"escalation_assignee",
sa.Text,
nullable=True,
comment="Slack user ID of the human to DM on escalation (e.g. U0HUMANID)",
),
)
# Add natural_language_escalation column — NOT NULL with default False
op.add_column(
"agents",
sa.Column(
"natural_language_escalation",
sa.Boolean,
nullable=False,
server_default=sa.text("FALSE"),
comment="Whether natural language escalation phrases trigger handoff",
),
)
def downgrade() -> None:
op.drop_column("agents", "natural_language_escalation")
op.drop_column("agents", "escalation_assignee")