Skip to content

feat(agent): item 12 子代理自动后台化阈值 FUSION_SUBAGENT_AUTO_BACKGROUND_MS (CC 2.1.198/232) - #103

Merged
dahai80 merged 1 commit into
mainfrom
feat/item12-subagent-auto-background
Aug 20, 2026
Merged

feat(agent): item 12 子代理自动后台化阈值 FUSION_SUBAGENT_AUTO_BACKGROUND_MS (CC 2.1.198/232)#103
dahai80 merged 1 commit into
mainfrom
feat/item12-subagent-auto-background

Conversation

@dahai80

@dahai80 dahai80 commented Aug 20, 2026

Copy link
Copy Markdown
Owner

背景

Closes #102。enhance-0819.md item 12 (CC 2.1.198/232): 子代理默认后台化。

缺口

现 subagent 走 sync foreground 阻塞 turn (toolExecution.ts:1392 await)。getAutoBackgroundMs() (AgentTool.tsx:161) 仅读 CLAUDE_AUTO_BACKGROUND_TASKS/GrowthBook tengu_auto_background_agents, default 0=off。OSS 构建 GrowthBook 不生效 → subagent 永不自动后台。item 4 (PR #94) 已为 MCP 落 FUSION_MCP_AUTO_BACKGROUND_MS, 但 subagent 走独立路径 (AgentTool/LocalAgentTask), 不共享代码。

方案 (surgical)

  • src/tools/AgentTool/autoBackground.ts: getSubagentAutoBackgroundMs() 解析 FUSION_SUBAGENT_AUTO_BACKGROUND_MS env (parseInt, default 0=off, 负数/非数 fail-off)。
  • getAutoBackgroundMs() 加 fusion env 分支 (在 CLAUDE_AUTO_BACKGROUND_TASKS/GrowthBook 前), 正值即返回。
  • 复用现成 registerAgentForeground 定时器 (LocalAgentTask.tsx:590-616) → backgroundSignal → mid-run 后台化 (AgentTool.tsx:1263) 解阻塞 turn。
  • default off, env 未设/0 → byte-identical 旧行为。无需 QueryEngine 解耦。

验证

  • typecheck: 0 errors
  • 单测: subagentAutoBackground.test.ts 7 pass (env 解析全 edge case)
  • 全测: src/__tests__/ 187 pass, 0 fail
  • build + build:dev:full: pass
  • lint (changed files): clean (新文件 biome --write 对齐 tab/双引号)

跨工程规则

仅改 fusion-code。Commit trailer: Co-Authored-By: Claude Fable 5 noreply@anthropic.com

…C 2.1.198/232)

扩 getAutoBackgroundMs 加 fusion env 分支 FUSION_SUBAGENT_AUTO_BACKGROUND_MS
(并行 item 4 FUSION_MCP_AUTO_BACKGROUND_MS)。设正值 → subagent 运行该毫秒后
转后台, 复用现成 registerAgentForeground 定时器→backgroundSignal→mid-run
后台化解阻塞 turn。default 0=off, byte-identical 旧行为。无需 QueryEngine 解耦。

Closes #102

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dahai80
dahai80 merged commit 0df70dd into main Aug 20, 2026
1 check passed
@dahai80
dahai80 deleted the feat/item12-subagent-auto-background branch August 20, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

item 12: 子代理自动后台化阈值 FUSION_SUBAGENT_AUTO_BACKGROUND_MS (CC 2.1.198/232)

1 participant