Долгоживущий агент чата (только для managerIds, тестовый менеджер) и тайминг чата (chat_timing, миграция 016); тесты; docs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
40
packages/khb_common/migrations/016_chat_timing.sql
Normal file
40
packages/khb_common/migrations/016_chat_timing.sql
Normal file
@@ -0,0 +1,40 @@
|
||||
-- Тайминг обработки запроса в чате ассистента: от сообщения в Slack до ответа в Slack, по этапам (диагностика медленных ответов).
|
||||
create table chat_timing (
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
created_at timestamptz not null default now(),
|
||||
manager_person_id uuid references construction_manager(person_id),
|
||||
channel_id text,
|
||||
kind text not null check (kind in ('message', 'event')),
|
||||
agent_version text not null check (agent_version in ('classic', 'live')),
|
||||
status text not null check (status in ('ok', 'failed')),
|
||||
error text,
|
||||
message_ts text,
|
||||
message_at timestamptz, -- время первого сообщения пакета в Slack (из ts)
|
||||
received_at timestamptz, -- когда сообщение принято сервисом (журнал slack_message_log)
|
||||
started_at timestamptz not null, -- начало обработки пакета (после ожидания debounce)
|
||||
reply_slack_ts text, -- ts ответа ассистента, полученный от Slack
|
||||
reply_at timestamptz, -- время ответа в Slack (из reply_slack_ts)
|
||||
slack_in_ms integer, -- Slack -> сервис (received_at - message_at)
|
||||
debounce_ms integer, -- ожидание накопления сообщений (started_at - received_at)
|
||||
inputs_ms integer, -- история напоминаний и вложения (скачивание)
|
||||
drive_ms integer, -- выгрузка исходников в Drive
|
||||
prompt_ms integer, -- сборка промта (запросы к БД, текст)
|
||||
prompt_chars integer,
|
||||
queue_ms integer, -- ожидание очереди менеджера и пула агентов
|
||||
start_ms integer, -- старт процесса агента и прогрев (live; для classic не измеряется отдельно)
|
||||
model_ms integer, -- от отправки промта до результата (все попытки)
|
||||
api_ms integer, -- время запросов к API модели по данным claude
|
||||
first_event_ms integer, -- до первого события хода (live)
|
||||
tool_calls integer,
|
||||
num_turns integer,
|
||||
attempts integer, -- вызовов модели (повторы "исправь формат")
|
||||
cost_usd numeric(10, 4),
|
||||
post_ms integer, -- сохранение памяти, проблем, истории
|
||||
publish_ms integer, -- отправка ответа в Slack (с озвучиванием)
|
||||
final_ms integer, -- повторная выгрузка в Drive после ответа
|
||||
processing_ms integer, -- вся обработка пакета (started_at -> конец)
|
||||
total_ms integer, -- от сообщения в Slack до ответа в Slack (message_at -> reply_at)
|
||||
steps jsonb -- подробности: вызовы модели с таймингом
|
||||
);
|
||||
create index chat_timing_manager_idx on chat_timing (manager_person_id, created_at desc);
|
||||
alter table chat_timing enable row level security;
|
||||
Reference in New Issue
Block a user