feat(agent): worker 单次 run 墙钟默认 600→1200
改默认不动存量行:CREATE 列默认 + 幂等 ALTER COLUMN SET DEFAULT 补旧库列默认(仅影响将来新插入)、seedBuiltins 种子默认、运行时兜底同步 1200。 旧库存量 agent 行保持原值不变。 Claude-Session: https://claude.ai/code/session_01Qx86izpr6f5R53DW864bPB
This commit is contained in:
1 parent
0fc63ad94e
commit
a98081eea9
3 files changed
+8
-6
No files matched your search
@@ -103,7 +103,7 @@ type builtinAgent struct {
|
||||
key, name, role, desc string
|
||||
vars []promptVar
|
||||
interactiveShell bool // 建行时的默认交互式 shell 开关;ON CONFLICT 不覆盖用户后续手动开关
|
||||
runSeconds *int // 建行时的单次 run 墙钟上限(秒);nil=用表默认(600),0=不限时
|
||||
runSeconds *int // 建行时的单次 run 墙钟上限(秒);nil=用种子默认(1200),0=不限时
|
||||
}
|
||||
|
||||
type promptVar struct{ name, desc, example, source string }
|
||||
@@ -144,7 +144,7 @@ func (d *DB) seedBuiltins() error {
|
||||
var agentID int64
|
||||
err := d.QueryRow(`
|
||||
INSERT INTO agents(key, name, description, role, builtin, enabled, interactive_shell, run_seconds)
|
||||
VALUES ($1, $2, NULLIF($3,''), $4, true, true, $5, COALESCE($6, 600))
|
||||
VALUES ($1, $2, NULLIF($3,''), $4, true, true, $5, COALESCE($6, 1200))
|
||||
ON CONFLICT (key) DO UPDATE SET name = EXCLUDED.name, description = EXCLUDED.description
|
||||
RETURNING id`, a.key, a.name, a.desc, a.role, a.interactiveShell, a.runSeconds).Scan(&agentID)
|
||||
if err != nil {
|
||||
|
||||
+3
-1
@@ -414,7 +414,7 @@ CREATE TABLE IF NOT EXISTS agents (
|
||||
llm_profile_id BIGINT REFERENCES llm_profiles(id) ON DELETE SET NULL,
|
||||
current_prompt_id BIGINT,
|
||||
max_turns INTEGER NOT NULL DEFAULT 0,
|
||||
run_seconds INTEGER NOT NULL DEFAULT 600,
|
||||
run_seconds INTEGER NOT NULL DEFAULT 1200,
|
||||
web_search BOOLEAN NOT NULL DEFAULT false,
|
||||
interactive_shell BOOLEAN NOT NULL DEFAULT false,
|
||||
wrapup_prompt TEXT NOT NULL DEFAULT '',
|
||||
@@ -434,6 +434,8 @@ ALTER TABLE agents ADD COLUMN IF NOT EXISTS trigger_merge_mode TEXT NOT NUL
|
||||
ALTER TABLE agents ADD COLUMN IF NOT EXISTS trigger_max_parallel INTEGER NOT NULL DEFAULT 5;
|
||||
-- per-agent LLM 绑定(agent 级默认模型):列自初版即在上方 CREATE 中,此 ALTER 仅为极旧库兜底(幂等)。
|
||||
ALTER TABLE agents ADD COLUMN IF NOT EXISTS llm_profile_id BIGINT REFERENCES llm_profiles(id) ON DELETE SET NULL;
|
||||
-- run_seconds 单次 run 墙钟默认 600→1200:只改列默认(影响将来新插入的行),不动旧库存量行。
|
||||
ALTER TABLE agents ALTER COLUMN run_seconds SET DEFAULT 1200;
|
||||
CREATE INDEX IF NOT EXISTS idx_agents_llm_profile ON agents(llm_profile_id) WHERE llm_profile_id IS NOT NULL;
|
||||
DROP TRIGGER IF EXISTS trg_agents_upd ON agents;
|
||||
CREATE TRIGGER trg_agents_upd BEFORE UPDATE ON agents
|
||||
|
||||
+3
-3
@@ -275,14 +275,14 @@ func (s *Server) agentMaxTurns(key string) int {
|
||||
}
|
||||
|
||||
// agentRunSeconds returns the configured wall-clock run budget (seconds) for an
|
||||
// agent key (0 = unlimited; 600 fallback when no DB or no row, matching schema).
|
||||
// agent key (0 = unlimited; 1200 fallback when no DB or no row, matching schema).
|
||||
func (s *Server) agentRunSeconds(key string) int {
|
||||
if s.m.pg == nil {
|
||||
return 600
|
||||
return 1200
|
||||
}
|
||||
a, err := s.m.pg.GetAgentByKey(key)
|
||||
if err != nil || a == nil {
|
||||
return 600
|
||||
return 1200
|
||||
}
|
||||
return a.RunSecs
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user