| 02-agent-features |
04 |
orchestrator |
| escalation |
| handoff |
| slack-api |
| redis |
| celery |
| pydantic |
| postgres |
| alembic |
|
| phase |
provides |
| 02-01 |
get_recent_messages for transcript assembly; Redis short-term memory infrastructure |
|
|
| Escalation rule evaluator: 'keyword AND count > N' condition parser + natural language phrase detection |
| Conversation transcript packager: Slack mrkdwn format with 3000-char truncation |
| Human DM delivery: Slack conversations.open + chat.postMessage via httpx |
| Escalation status tracking in Redis: escalation_status_key sets 'escalated' flag |
| Post-escalation assistant mode: end-user messages to escalated threads get auto-reply, skipping LLM |
| Agent model fields: escalation_assignee (Slack user ID), natural_language_escalation (bool) |
| Alembic migration 003: adds escalation_assignee and natural_language_escalation to agents table |
| No-op audit logger stub for escalation events (replaced when Plan 02 audit module ships) |
|
| 02-02 (audit) — escalation events use no-op logger stub, ready for real AuditLogger swap |
| tasks.py pipeline — escalation pre/post checks integrated around LLM call |
|
| added |
patterns |
|
|
| Condition parsing: 'keyword AND count_field > N' format, regex-based, no eval() |
| TDD pattern: RED (failing tests committed) then GREEN (implementation committed) |
| Escalation pre-check before LLM: Redis flag gates whether LLM is called at all |
| No-op logger stub: allows feature to work before audit plan is implemented |
|
|
| created |
modified |
| packages/orchestrator/orchestrator/escalation/__init__.py |
| packages/orchestrator/orchestrator/escalation/handler.py |
| migrations/versions/003_escalation_fields.py |
| tests/unit/test_escalation.py |
| tests/integration/test_escalation.py |
|
| packages/shared/shared/models/tenant.py |
| packages/orchestrator/orchestrator/tasks.py |
|
|
| Keyword-based conversation metadata detection (v1): billing keywords + attempt counter from sliding window — simple and sufficient for initial rules |
| Natural language escalation condition uses literal string 'natural_language_escalation' in escalation_rules config — matches plan spec |
| Bot token loaded unconditionally in _process_message (not gated on placeholder_ts) — escalation DM needs it regardless of Slack placeholder presence |
| No-op audit logger stub in tasks.py: escalation works independently of Plan 02 audit module; swap is a one-line change |
| Condition parser uses regex (not eval): safe, deterministic, no code injection risk |
|
| Escalation check is two-phase: pre-LLM (assistant mode gate) and post-LLM (rule trigger) |
| assistant mode: escalated thread + end user sender → skip LLM entirely, return static reply |
| Escalation DM format follows employee metaphor: '{agent.name} needs human assistance' |
|
|
5min |
2026-03-23 |