Skip to content

Commit 9c0a58f

Browse files
committed
feat(kimi-agent): persist Task-tool subagent conversations (replay data source)
- the native Task tool now runs tracked subagents through run_child_agent_persistent_with_model (agent_id = task_id), the same session-store persistence swarm children use — the resume surface gets a host-visible subagent data source it previously lacked - untracked bare agents keep the non-persistent path - migration plan updated: vscode legacy backfill verified closed, gap list trimmed
1 parent 58178d2 commit 9c0a58f

2 files changed

Lines changed: 47 additions & 20 deletions

File tree

CODEX_MIGRATION_PLAN.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@
4747
## 1.4 已知缺口(不阻塞主线的记录)
4848

4949
1. **compaction summarizer 双通道**:引擎 summarizer 仅支持 native LLM;host-proxy 会话(SDK 默认 llmStep)compact 报 `compaction.unable`。SDK 侧已按 `agent.nativeLlmProvider` 显式 opt-in 接线(不自动派生——native_llm 会使引擎回合脱离宿主 llmStep,破坏 host identity UA/事件流)。需引擎支持 summarizer 独立通道
50-
2. **子代理 replay 无数据源**:引擎 `Task` 工具无 host-visible 记录,resume 面无 subagent 数据(vscode 测试已跳过)
51-
3. **vscode legacy backfill 链路未闭环**`kimi_cli_source_path``vscode_legacy_approval` metadata 回填(测试已跳过)
52-
4. **用户真实 config.toml 损坏**`duplicate defaultModel`(defaultModel 与 default_model 并存)导致 Rust TOML 严格解析拒绝整个配置(用户禁止修改真实文件,隔离配置验证绕开;建议用户侧删 camelCase 行)
50+
2. **子代理 replay 数据源**:🔶 部分补(2026-08-10):Task 工具子代理在任务被跟踪时(task_service 存在)经 `run_child_agent_persistent_with_model` 持久化对话到 session store(agent_id = task_id,swarm 同一机制)——resume 面的**数据源已建立**;剩余:resume/session RPC 的 `include_subagents` 读取面(引擎无此参数)待补,vscode replay 测试仍跳过
51+
3. **用户真实 config.toml 损坏**`duplicate defaultModel`(defaultModel 与 default_model 并存)导致 Rust TOML 严格解析拒绝整个配置(用户禁止修改真实文件,隔离配置验证绕开;建议用户侧删 camelCase 行)
5352

54-
> **2026-08-10 收口复核**:原第 4-6 项已消失——vscode typecheck 全过(`replay-adapter.ts` 错误已随 sdk-local 完成消除);kosong 已退役(flaky 测试随包);发布打包已接入 CI(`_rust-bin-build.yml` + release 注入)。另:apps/kimi-code 的 `@moonshot-ai/kimi-agent` devDep 已删(全仓无真实 import,仅注释引用 wire.gen)。
53+
> **2026-08-10 收口复核**:原第 4-6 项已消失——vscode typecheck 全过(`replay-adapter.ts` 错误已随 sdk-local 完成消除);kosong 已退役(flaky 测试随包);发布打包已接入 CI(`_rust-bin-build.yml` + release 注入)**vscode legacy backfill 已闭环**(kimi-runtime.ts 迁移会话读 `kimi_cli_source_path` → 写 `vscode_legacy_approval` metadata → session-runtime 消费,create/resume 全链路完整)。另:apps/kimi-code 的 `@moonshot-ai/kimi-agent` devDep 已删(全仓无真实 import,仅注释引用 wire.gen)。
5554
5655
---
5756

packages/kimi-agent/src/agent/agent.rs

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
use std::sync::Arc;
99
use std::sync::atomic::{AtomicBool, Ordering};
1010

11-
use crate::agent::subagent::{run_child_agent, run_child_agent_with_model};
11+
use crate::agent::subagent::{
12+
run_child_agent, run_child_agent_persistent_with_model, run_child_agent_with_model,
13+
};
1214
use crate::agent::types::*;
1315
use crate::callbacks::HostCallbacks;
1416
use crate::callbacks::NativeToolCallbacks;
@@ -604,21 +606,47 @@ impl HostCallbacks for SubagentInterceptor {
604606
});
605607

606608
Box::pin(async move {
607-
match run_child_agent_with_model(
608-
host,
609-
homedir,
610-
native_llm,
611-
permission,
612-
&parent_prompt,
613-
max_steps,
614-
child_depth,
615-
&subagent_type,
616-
&prompt,
617-
hooks,
618-
model_override,
619-
)
620-
.await
621-
{
609+
// Persist the child's conversation when the task is tracked
610+
// (agent_id = task_id), so the resume surface has a subagent data
611+
// source (G-2 replay gap): swarm children persist the same way.
612+
// Untracked bare agents keep the non-persistent path.
613+
let run_result = match task_id {
614+
Some(ref id) => {
615+
run_child_agent_persistent_with_model(
616+
host,
617+
homedir,
618+
native_llm,
619+
permission,
620+
&parent_prompt,
621+
max_steps,
622+
child_depth,
623+
&subagent_type,
624+
&prompt,
625+
hooks,
626+
id,
627+
model_override,
628+
)
629+
.await
630+
.map(|(_agent_id, text)| text)
631+
}
632+
None => {
633+
run_child_agent_with_model(
634+
host,
635+
homedir,
636+
native_llm,
637+
permission,
638+
&parent_prompt,
639+
max_steps,
640+
child_depth,
641+
&subagent_type,
642+
&prompt,
643+
hooks,
644+
model_override,
645+
)
646+
.await
647+
}
648+
};
649+
match run_result {
622650
Ok(text) => {
623651
settle_task(&task_service, &task_id, false, None);
624652
if let (Some(ts), Some(id)) = (&task_service, &task_id) {

0 commit comments

Comments
 (0)