feat(agent): 按任务/意图预建 agent 工作目录,worker 免手动建目录

- 新增 ensureRunDir(base,taskID,intentID):os.MkdirAll 建
  <workDir>/<taskID>[/i<intentID>],返回路径;cmdOutDir 助手
- worker:CWD/ToolOutputDir/提示词指到 <workDir>/<taskID>/i<意图id>/
  (引擎预建),删 workerArtifactSubdir,新 workerArtifactSpec 文案
- planner/mainagent:补 WorkingDir=<workDir>/<taskID>/ + ToolOutputDir
  (此前根本没设 WorkingDir);artifactSpec 文案改为「本任务工作目录」

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Autumn-27andClaude Opus 4.8 committed 2026-08-09 00:40:31 -04:00
1 parent f7197da988
commit 5f0fac33aa
3 files changed
+53 -22

No files matched your search

+10 -6
View File
@@ -8,12 +8,12 @@ import (
"sync"
"time"
"github.com/Autumn-27/artex/db"
"github.com/Autumn-27/norma/agentcore"
"github.com/Autumn-27/norma/llm"
"github.com/Autumn-27/norma/permission"
actool "github.com/Autumn-27/norma/tool"
"github.com/Autumn-27/norma/transcript"
"github.com/Autumn-27/artex/db"
)
// Planner is the event-driven LLM planner (docs §4.3): each time the asset or
@@ -197,7 +197,9 @@ func (p *Planner) Plan(ctx context.Context, taskID int64, as *db.AssetStore, ts
if tc.Final {
situational += "\n\n【任务终局收尾(本轮特殊指令,覆盖上面的常规规划流程)】:" + resolveTaskTimeoutWrapup("planner")
}
system, boundary := deferredSystem(plannerSystem(goal, p.workDir)+situational, def)
// 本任务的工作目录 <workDir>/<taskID>,先建好。
taskDir := ensureRunDir(p.workDir, taskID, 0)
system, boundary := deferredSystem(plannerSystem(goal, taskDir)+situational, def)
// planner 无自身墙钟预算;有 deadline 时把 MaxDuration 夹逼到剩余,让在跑的规划轮在
// 任务到点时进收尾(因超时→任务超时词,因步数→per-run 词)。
maxDur, clamped := clampMaxDuration(tc.DeadlineUnix, 0)
@@ -223,10 +225,12 @@ func (p *Planner) Plan(ctx context.Context, taskID int64, as *db.AssetStore, ts
BraveSearchAPIKey: p.webSearch.BraveKey,
TavilySearchAPIKey: p.webSearch.TavilyKey,
WebSearchProxy: p.webSearch.Proxy,
BashEnv: proxyEnv(p.proxyAddr, p.proxyCACert), // Bash 子命令默认走代理+信任 CA
MaxTurns: p.maxTurns, // 0 = unlimited (configurable in agent management)
MaxDuration: maxDur, // 0=不限;有 deadline 时=距 deadline 剩余
Compaction: compactionConfig(p.window),
BashEnv: proxyEnv(p.proxyAddr, p.proxyCACert), // Bash 子命令默认走代理+信任 CA
WorkingDir: taskDir, // 本任务工作目录 <workDir>/<taskID>
ToolOutputDir: cmdOutDir(taskDir),
MaxTurns: p.maxTurns, // 0 = unlimited (configurable in agent management)
MaxDuration: maxDur, // 0=不限;有 deadline 时=距 deadline 剩余
Compaction: compactionConfig(p.window),
// 跨唤醒共享的规划待办:让串行链在多轮之间保留(session 是新的,store 不是)。
Todos: p.todoFor(ts.ID()),
// 命中【本轮】步数预算→ SDK 跑收尾:把本轮已想清楚的结论落地(该派的 add_intent、