feat(智能体): 不设硬性预算上限,花费改为可见
- 去掉每天次数、每天花费、单次花费、单次 token 四个上限的拦截;设置项登记为弃用,旧值兼容读取、不生效 - 保留单次工具调用次数与时长两个防跑飞限制,缺省调宽(120 次 / 1800 秒,后台调查 20 次) - 新增 GET /agent/usage:今天与最近 7 天按会话类型(对话 / 巡检 / 后台调查 / 整理识别 / 子会话)的次数、token 与费用 - 设置 agent.autoIdentifyOrganize(整理识别不到时叫智能体识别,缺省开)一并加在智能体设置里 - runner 里加整理识别会话的能力白名单与调查会话去重键解析(investigationDecisionId) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
7b7fadbfb6
commit
414ea7c890
10 files changed
+259
-48
No files matched your search
@@ -359,6 +359,23 @@ export type AgentRunChoiceInput = z.infer<typeof AgentRunChoiceInput>;
|
||||
export const AgentRunAbortInput = z.object({ reason: z.string().max(500).optional() });
|
||||
export type AgentRunAbortInput = z.infer<typeof AgentRunAbortInput>;
|
||||
|
||||
/**
|
||||
* 智能体用量(2026-10-06 起不设硬性预算上限,花费改为可见):按会话类型统计次数、token 与费用。
|
||||
* chat = 用户对话;patrol = 智能体巡检;investigate = 待处理事项的后台调查 / 授权内恢复;
|
||||
* organize_identify = 整理没识别出作品时的智能体识别;subagent = 子会话
|
||||
*/
|
||||
export const AgentSpendKind = z.enum(["chat", "patrol", "investigate", "organize_identify", "subagent"]);
|
||||
export type AgentSpendKind = z.infer<typeof AgentSpendKind>;
|
||||
export const AgentSpendBucket = z.object({
|
||||
runs: NonNegInt,
|
||||
tokens: NonNegInt,
|
||||
costUsd: z.number().min(0),
|
||||
byKind: z.array(z.object({ kind: AgentSpendKind, runs: NonNegInt, tokens: NonNegInt, costUsd: z.number().min(0) })),
|
||||
});
|
||||
export type AgentSpendBucket = z.infer<typeof AgentSpendBucket>;
|
||||
export const AgentSpend = z.object({ today: AgentSpendBucket, last7d: AgentSpendBucket });
|
||||
export type AgentSpend = z.infer<typeof AgentSpend>;
|
||||
|
||||
export const AgentRunListQuery = z.object({
|
||||
cursor: z.string().min(1).optional(),
|
||||
limit: z.coerce.number().int().min(1).max(200).default(50),
|
||||
|
||||
@@ -77,6 +77,13 @@ export const reviewApi = {
|
||||
),
|
||||
/** Agent 会话(W2-D):建 run 只入队持久任务 runAgent;增量经全局 SSE(agent.*),断线按 runSeq 用 afterSeq 补读 */
|
||||
agentRuns: {
|
||||
usage: ep({
|
||||
method: "get",
|
||||
path: "/agent/usage",
|
||||
scope: "read",
|
||||
summary: "智能体用量:今天与最近 7 天按会话类型的次数、token 与费用",
|
||||
response: agent.AgentSpend,
|
||||
}),
|
||||
list: ep({
|
||||
method: "get",
|
||||
path: "/agent/runs",
|
||||
|
||||
@@ -208,10 +208,12 @@ export const AgentRuntimeSettings = z.object({
|
||||
.int()
|
||||
.min(10)
|
||||
.max(24 * 3600),
|
||||
/** 单次运行:token 上限(null = 不限) */
|
||||
maxTokensPerRun: z.number().int().positive().nullable(),
|
||||
/** 单次运行:费用上限(美元,null = 不限) */
|
||||
maxCostUsdPerRun: z.number().positive().nullable(),
|
||||
/** 已弃用(2026-10-06 起不限 token,旧值兼容读取、不生效) */
|
||||
maxTokensPerRun: z.number().int().positive().nullable().optional(),
|
||||
/** 已弃用(2026-10-06 起不限单次费用,旧值兼容读取、不生效) */
|
||||
maxCostUsdPerRun: z.number().positive().nullable().optional(),
|
||||
/** 整理时没识别出作品:自动派智能体识别一次,认出来就按该作品重新整理(不需要持续授权) */
|
||||
autoIdentifyOrganize: z.boolean(),
|
||||
/** 后台自动调查的工具调用上限(比用户委托更小) */
|
||||
investigateMaxToolCalls: z.number().int().min(1).max(100),
|
||||
/** 等待目标关联的下载/入库结束时的轮询间隔(秒) */
|
||||
@@ -432,8 +434,10 @@ export const BudgetSettings = z.object({
|
||||
maxNewTitlesPerDay: z.number().int().min(0),
|
||||
maxDownloadBytesPerDay: z.number().int().min(0),
|
||||
maxConcurrentDownloads: z.number().int().min(1).max(100),
|
||||
agentMaxRunsPerDay: z.number().int().min(0),
|
||||
agentMaxCostUsdPerDay: z.number().min(0),
|
||||
/** 已弃用(2026-10-06 起智能体不设每日次数上限,旧值兼容读取、不生效) */
|
||||
agentMaxRunsPerDay: z.number().int().min(0).optional(),
|
||||
/** 已弃用(2026-10-06 起智能体不设每日费用上限,旧值兼容读取、不生效) */
|
||||
agentMaxCostUsdPerDay: z.number().min(0).optional(),
|
||||
});
|
||||
export type BudgetSettings = z.infer<typeof BudgetSettings>;
|
||||
|
||||
@@ -667,19 +671,16 @@ export const DEFAULT_SETTINGS: GlobalSettings = {
|
||||
maxNewTitlesPerDay: 20,
|
||||
maxDownloadBytesPerDay: 500 * 1024 ** 3,
|
||||
maxConcurrentDownloads: 5,
|
||||
agentMaxRunsPerDay: 50,
|
||||
agentMaxCostUsdPerDay: 5,
|
||||
},
|
||||
agent: {
|
||||
autoInvestigate: false,
|
||||
autoInvestigateMode: "investigate",
|
||||
investigateMaxAttempts: 2,
|
||||
recoverVerifySec: 600,
|
||||
maxToolCalls: 40,
|
||||
maxDurationSec: 900,
|
||||
maxTokensPerRun: null,
|
||||
maxCostUsdPerRun: null,
|
||||
investigateMaxToolCalls: 8,
|
||||
maxToolCalls: 120,
|
||||
maxDurationSec: 1800,
|
||||
autoIdentifyOrganize: true,
|
||||
investigateMaxToolCalls: 20,
|
||||
goalPollSec: 60,
|
||||
goalWaitHours: 72,
|
||||
optionsTimeoutSec: 1800,
|
||||
@@ -858,6 +859,11 @@ export const DEPRECATED_SETTINGS_FIELDS = [
|
||||
"cache.tmdbTtlHours",
|
||||
"cache.emptyResultTtlSec",
|
||||
"identity.poolArchiveDays",
|
||||
// 2026-10-06:智能体不设硬性预算上限,只保留单次工具调用次数与时长两个防跑飞限制
|
||||
"budget.agentMaxRunsPerDay",
|
||||
"budget.agentMaxCostUsdPerDay",
|
||||
"agent.maxTokensPerRun",
|
||||
"agent.maxCostUsdPerRun",
|
||||
] as const;
|
||||
|
||||
// ── 设置页分区(docs/design/console-ia.md §3.4) ──
|
||||
@@ -1027,12 +1033,12 @@ export const SETTINGS_SECTIONS: readonly SettingsSectionDef[] = [
|
||||
{
|
||||
id: "agent",
|
||||
label: "智能体",
|
||||
description: "模型服务、运行预算、自动调查、网页搜索",
|
||||
description: "模型服务、用量与限制、自动调查、网页搜索",
|
||||
legacyTabs: [{ tab: "pi" }],
|
||||
anchors: [
|
||||
{ id: "upstream", label: "模型服务" },
|
||||
{ id: "runtime", label: "上下文与子会话" },
|
||||
{ id: "budget", label: "预算" },
|
||||
{ id: "budget", label: "用量与限制" },
|
||||
{ id: "investigate", label: "自动调查" },
|
||||
{ id: "websearch", label: "网页搜索" },
|
||||
{ id: "advanced", label: "高级" },
|
||||
@@ -1045,16 +1051,13 @@ export const SETTINGS_SECTIONS: readonly SettingsSectionDef[] = [
|
||||
"pi.compaction",
|
||||
"pi.subagentsEnabled",
|
||||
"pi.subagents",
|
||||
"budget.agentMaxRunsPerDay",
|
||||
"budget.agentMaxCostUsdPerDay",
|
||||
"agent.autoInvestigate",
|
||||
"agent.autoIdentifyOrganize",
|
||||
"agent.autoInvestigateMode",
|
||||
"agent.investigateMaxAttempts",
|
||||
"agent.recoverVerifySec",
|
||||
"agent.maxToolCalls",
|
||||
"agent.maxDurationSec",
|
||||
"agent.maxTokensPerRun",
|
||||
"agent.maxCostUsdPerRun",
|
||||
"agent.investigateMaxToolCalls",
|
||||
"agent.goalPollSec",
|
||||
"agent.goalWaitHours",
|
||||
|
||||
Reference in new issue
Block a user