Агенты: учёт токенов (agent_usage, буфер в памяти + пачки в БД), globals с лимитами аккаунта, доллары убраны
Расчётная стоимость из ответов claude не является списанием (тариф Team, 0 из 10 USD), поэтому результаты, API и записи больше её не ведут. Токены каждого вызова модели - в agent_usage; проценты 5-часового и недельного окон читаются у claude в globals (одна строка, check), предупреждение ИТ на 80% и 95%, сводка GET /agent/usage. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -319,7 +319,7 @@ ${recapBlock(st, deps.timezone)}`);
|
||||
// 4. агент
|
||||
let out;
|
||||
try {
|
||||
out = await runManagerAgent(ctx, { managerId: manager.personId, step: "step4", tools: "chat", prompt, fullPrompt, env: sqlEnv, required: [replyKey, "память"] });
|
||||
out = await runManagerAgent(ctx, { managerId: manager.personId, step: "step4", op: opts.project ? "chat:project" : opts.systemEvent ? "chat:event" : "chat:manager", tools: "chat", prompt, fullPrompt, env: sqlEnv, required: [replyKey, "память"] });
|
||||
tm.agent = out.timing;
|
||||
mark = Date.now();
|
||||
} catch (e) {
|
||||
|
||||
@@ -54,7 +54,8 @@ export async function saveChatTiming(pool: Pool, t: ChatTiming, log?: { warn(o:
|
||||
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),
|
||||
int(sum(runs.map((r) => r.timing?.startMs))), int(modelMs), int(sum(runs.map((r) => r.timing?.apiMs))), int(runs[0]?.timing?.firstEventMs),
|
||||
int(sum(runs.map((r) => r.timing?.toolCalls))), int(sum(runs.map((r) => r.timing?.numTurns))), runs.length || null, sum(runs.map((r) => r.costUsd)),
|
||||
int(sum(runs.map((r) => r.timing?.toolCalls))), int(sum(runs.map((r) => r.timing?.numTurns))), runs.length || null, null, // cost_usd не ведётся: токены - в agent_usage
|
||||
|
||||
int(t.postMs), int(t.publishMs), int(t.finalMs), int(t.processingMs), int(messageAt && replyAt ? replyAt.getTime() - messageAt.getTime() : null),
|
||||
JSON.stringify({ runs }),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user