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

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 [email protected]

…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 <[email protected]>
@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
dahai80 added a commit that referenced this pull request Aug 22, 2026
Patch release bundling 17 commits since v0.4.23:
- item 15(a) MLX OOM auto-recovery gc+retry (#129)
- #7 one-click diagnostic fixAction framework (#131)
- 维度5 background-default spawn FUSION_SUBAGENT_DEFAULT_BACKGROUND (#127)
- #4 proactive MLX OOM detection via /v1/health (#125)
- item 17 fullscreen pre-compact history + :598 synthetic decouple (#123)
- item 25B workflow stagger fan-out (#122)
- item 21 auto-mode local rule classifier test coverage (#120)
- item 23 archive plugin source + SHA-256 lock (#118)
- item 24 marketplace command source (#116)
- item 6 transcript disk trimming + crash-safe checkpoint (#114)
- item 5 normalizeMessages secondary normalize cache (#112)
- item 19 screen-reader plaintext render (#110)
- item 16 compact retry countdown + stall hint (#108)
- item 25A workflow execution runtime docs (#106)
- item 25A minimal workflow execution runtime (#105)
- item 12 subagent auto-background threshold (#103)
- item 20 vimInsertModeRemaps dual-key INSERT sequence (#101)

Co-Authored-By: Claude Fable 5 <[email protected]>
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