Короткое напоминание только если осмысленное сообщение было менее 24 часов назад (last_meaningful, миграция 039, п.86)
All checks were successful
ci / test (push) Successful in 38s
ci / deploy (push) Successful in 2m37s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 08:47:46 +03:00
parent 198eafa86f
commit 213ef36bcf
9 changed files with 35 additions and 13 deletions

View File

@@ -11,6 +11,8 @@ export interface ChatTiming {
messageTs?: string;
receivedAt?: Date | null;
replySlackTs?: string | null;
/** Длина ответа в словах без упоминаний: по ней отличаем короткое напоминание от осмысленного сообщения. */
replyWords?: number | null;
inputsMs?: number;
driveMs?: number;
promptMs?: number;
@@ -44,12 +46,12 @@ export async function saveChatTiming(pool: Pool, t: ChatTiming, log?: { warn(o:
const replyAt = slackTsToDate(t.replySlackTs);
const modelMs = sum(runs.map((r) => r.timing?.turnMs ?? r.wallMs));
await pool.query(
`insert into chat_timing (manager_person_id, channel_id, kind, agent_version, status, error, message_ts, message_at, received_at, started_at, reply_slack_ts, reply_at,
`insert into chat_timing (manager_person_id, channel_id, kind, agent_version, status, error, message_ts, message_at, received_at, started_at, reply_slack_ts, reply_at, reply_words,
slack_in_ms, debounce_ms, inputs_ms, drive_ms, prompt_ms, prompt_chars, queue_ms, start_ms, model_ms, api_ms, first_event_ms, tool_calls, num_turns, attempts, cost_usd,
post_ms, publish_ms, final_ms, processing_ms, total_ms, steps)
values ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33)`,
values ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34)`,
[
t.managerId, t.channel, t.kind, t.agentVersion, t.status, t.error?.slice(0, 500) ?? null, t.messageTs ?? null, messageAt, t.receivedAt ?? null, t.startedAt, t.replySlackTs ?? null, replyAt,
t.managerId, t.channel, t.kind, t.agentVersion, t.status, t.error?.slice(0, 500) ?? null, t.messageTs ?? null, messageAt, t.receivedAt ?? null, t.startedAt, t.replySlackTs ?? null, replyAt, t.replyWords ?? null,
int(messageAt && t.receivedAt ? t.receivedAt.getTime() - messageAt.getTime() : null),
int(t.receivedAt ? t.startedAt.getTime() - t.receivedAt.getTime() : null),
int(t.inputsMs), int(t.driveMs), int(t.promptMs), int(t.promptChars), int(t.agent?.queueMs),