MCP: короткий id во всех инструментах, журнал вызовов acc_mcp_log и представление acc_mcp_error_rate, расширены instructions
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
31
packages/khb_common/migrations/040_acc_mcp_log.sql
Normal file
31
packages/khb_common/migrations/040_acc_mcp_log.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
-- Журнал вызовов MCP accounting_automation: разбор ошибок и доли неудачных запросов, когда чата сотрудника не видно.
|
||||
create table if not exists acc_mcp_log (
|
||||
id bigserial primary key,
|
||||
at timestamptz not null default now(),
|
||||
person_id text,
|
||||
method text not null, -- tools/call, tools/list, initialize, resources/read ...
|
||||
tool text, -- имя инструмента для tools/call
|
||||
args jsonb, -- аргументы (усечённые)
|
||||
ok boolean not null,
|
||||
error_kind text, -- invalid_args | not_found | forbidden | internal | unknown_tool | rpc | partial
|
||||
error text,
|
||||
items_total int, -- для acc_review_batch: действий в пакете
|
||||
items_failed int, -- для acc_review_batch: неудачных действий
|
||||
duration_ms int,
|
||||
result_bytes int
|
||||
);
|
||||
create index if not exists acc_mcp_log_at_idx on acc_mcp_log (at desc);
|
||||
create index if not exists acc_mcp_log_tool_idx on acc_mcp_log (tool, at desc);
|
||||
|
||||
-- Доля ошибок по инструментам и дням: >3-5% = баг инструмента или мало инструкций.
|
||||
create or replace view acc_mcp_error_rate as
|
||||
select date_trunc('day', at)::date as day, tool,
|
||||
count(*) as calls,
|
||||
count(*) filter (where not ok or coalesce(items_failed, 0) > 0) as bad_calls,
|
||||
round(100.0 * count(*) filter (where not ok or coalesce(items_failed, 0) > 0) / count(*), 1) as bad_pct,
|
||||
coalesce(sum(items_total), 0) as batch_items,
|
||||
coalesce(sum(items_failed), 0) as batch_items_failed
|
||||
from acc_mcp_log
|
||||
where method = 'tools/call'
|
||||
group by 1, 2
|
||||
order by 1 desc, 2;
|
||||
Reference in New Issue
Block a user