Skip to content

feat(agent): mid-run guidance injection for background sub-agents - #7912

Open
bfxh wants to merge 3 commits into
esengine:main-v2from
bfxh:feat/subagent-steer
Open

feat(agent): mid-run guidance injection for background sub-agents#7912
bfxh wants to merge 3 commits into
esengine:main-v2from
bfxh:feat/subagent-steer

Conversation

@bfxh

@bfxh bfxh commented Aug 7, 2026

Copy link
Copy Markdown

Summary

zcode 式引导注入:主对话可向运行中的后台子智能体注入引导(mid-run guidance),
子智能体继续工作时主对话不被阻塞。

  • job steer 通道internal/jobs):Job.Steer + Manager.SteerJob(running 校验、
    完成置 nil、session 作用域);ctx 携带 job;OnAgentCreated 钩子 + wireSubagentSteer
  • 主对话自动转发internal/agent/steer_forward.go):/注入:/inject: 标记
    → 路由到最近 running task job;失败回退普通 turn(保守,不误吞)
  • orchestrator 接线internal/control):非 synthetic 输入命中标记才转发,
    转发成功发 Notice 且不发起主 turn
  • 持久化:注入消息经 consumeSteer 进子智能体会话
  • docs/AGENT_ARCHITECTURE.md:子智能体并发引导注入架构 + MCP 职责边界规则表

Verification

  • jobs 5 测试 + agent forward 6 测试 + persist 2 测试(-race 全绿)
  • jobs/agent/control 三包全量无回归

Notes

CI Declarations

Cache-impact: low - 引导注入走独立 steer 通道(jobs/steer_forward),不改变主对话 system prompt 前缀结构
Cache-guard: internal/agent/steer_forward_test.go + steer_persist_test.go + 既有 cachehit e2e 前缀稳定测试
System-prompt-review: 主对话前缀不变,注入消息作为独立用户消息附加(不破坏前缀字节稳定性)
Documentation-impact: updated - docs/AGENT_ARCHITECTURE.md(引导注入章节)+ docs/TOOL_CONTRACT.md

…b-agents + MCP boundary doc

Phase 1 - design (docs/AGENT_ARCHITECTURE.md): subagent concurrency +
guidance-injection architecture (auto-forward chain, concurrency safety,
fallback, persistence), MCP responsibility boundary rules (external
capabilities -> MCP, kernel logic -> built-in), risks & verification.

Phase 2 - implementation (zcode-style: main conversation keeps working while
a sub-agent runs, and marked user input is forwarded into the running
sub-agent's next turn):
- jobs: Job.steer callback (mu-guarded) + SetSteer + Manager.SteerJob
  (running-checked, session-scoped) + cleared on completion + JobFromContext;
- agent: Options.OnAgentCreated hook invoked with the child Agent so
  background task/fleet jobs wire job.SetSteer(sub.Steer) (wireSubagentSteer);
  consumeSteer already persists injected guidance into the child session
  (run_loop user message);
- agent/steer_forward.go: SteerForwarder — conservative auto-forward
  (explicit markers → / 注入: / inject: / 告诉子智能体 …; target = newest
  running task job; marker stripped; fallback to normal turn on any failure);
- control: runOrchestratedTurn forwards marked non-synthetic user input to a
  running sub-agent (Notice emitted, no main turn) — CLI/desktop both ride it.

Phase 3 - boundary codification: reasonix.example.toml plugins section gains
the MCP-vs-builtin responsibility comment; docs/TOOL_CONTRACT.md gains the
Capability Boundary section. No code migration needed (current surface
already follows external-MCP / kernel-builtin).

Tests: jobs steer_test (5, -race), agent steer_forward_test (6, -race) +
steer_persist_test (2); agent/control/jobs full suites green; go build ./...
clean; full repo 107 ok (3 known Windows-env failures unrelated).
@bfxh
bfxh requested review from SivanCola and esengine as code owners August 7, 2026 21:09
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development agent Core agent loop (internal/agent, internal/control) labels Aug 7, 2026
bfxh pushed a commit to bfxh/DeepSeek-Reasonix that referenced this pull request Aug 8, 2026
- §8 优化面补全(不止缓存):状态建模/上下文组装/流程建模/可观测性/记忆/审批安全
  六面,逐项标注对接 PR(esengine#7911 flywheel-toolcache / esengine#7912 subagent-steer / esengine#7791 OSWorld)
- §9 重复建模场景细分(R1-R6):任务模板复用/同目标重试/增量修改/跨会话同构/
  表面相似/全新——逐类判定是否值得语义缓存 + 细分判定流程 + 度量标准
  (只统计 R1/R3 命中,误判率>5% 收紧阈值,防刷命中率)
…on guard for esengine#7912

PR esengine#7912 (mid-turn steer guidance) appends steer as a fresh user message; it
must never splice into history or the prompt-cache prefix breaks. Add
TestCacheHitSteerPreservesPrefix: drives a 7-request run with a mid-turn steer
injected in a 150ms window and asserts every request's cached prefix equals
the ENTIRE prior request (hitChars[i]==reqChars[i-1]). mockDeepSeek gains a
mutex + per-request delay so the injection window is real and the test is
race-clean (-race passes).
bfxh pushed a commit to bfxh/DeepSeek-Reasonix that referenced this pull request Aug 8, 2026
…on guard for esengine#7912

PR esengine#7912 (mid-turn steer guidance) appends steer as a fresh user message; it
must never splice into history or the prompt-cache prefix breaks. Add
TestCacheHitSteerPreservesPrefix: drives a 7-request run with a mid-turn steer
injected in a 150ms window and asserts every request's cached prefix equals
the ENTIRE prior request (hitChars[i]==reqChars[i-1]). mockDeepSeek gains a
mutex + per-request delay so the injection window is real and the test is
race-clean (-race passes).
bfxh pushed a commit to bfxh/DeepSeek-Reasonix that referenced this pull request Aug 8, 2026
…OSWorld core

esengine#7791 boundary cleanup (step 3): remove the two cleanly-separable domains
(cosplay: 15 files — decided to drop; desktop/frontend: 5 PR esengine#7910 files).
boot/agent already decoupled from cosplay via cosplayhook (5675a52), so the
stripped branch compiles; golden re-recorded, code_verify removed from the
boot contract, eventwire skips when frontend is absent. flywheel/modeling/
steer stay as agent infrastructure (same code as esengine#7911/esengine#7967/esengine#7912, PR value
is separate review not physical separation).
bfxh pushed a commit to bfxh/DeepSeek-Reasonix that referenced this pull request Aug 8, 2026
…OSWorld core

Merged latest upstream (a720a3a) + main dev line, then removed the two
cleanly-separable domains: cosplay (15 files, decided to drop) and
desktop/frontend (5 PR esengine#7910 files). boot/agent already decoupled from
cosplay via cosplayhook, so the stripped tree compiles; golden re-recorded,
code_verify removed from the boot contract, eventwire skips when frontend is
absent. flywheel/modeling/steer remain as agent infrastructure (same code as
esengine#7911/esengine#7967/esengine#7912 — separate review, not physical separation).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant