Skip to content

feat(conversation): side conversation fork API#383

Open
taekchef wants to merge 4 commits into
iOfficeAI:mainfrom
taekchef:feat/side-conversation
Open

feat(conversation): side conversation fork API#383
taekchef wants to merge 4 commits into
iOfficeAI:mainfrom
taekchef:feat/side-conversation

Conversation

@taekchef
Copy link
Copy Markdown

@taekchef taekchef commented Jun 1, 2026

Summary

新增侧边会话 fork API —— 从主会话中分叉子会话的后端原语,支持多个侧边子会话和双 fork 策略。

改了什么

  • POST /api/conversations/{id}/side — 每次调用创建一个新的侧边子会话
    • 请求体:guardrail?(guardrail 文本)、initial_prompt?(首条用户消息)、forked_at_msg_id?(分叉点消息 ID)
    • 返回:conversation_idcreated: truefork_mode(由服务端根据 agent 能力自动决定)
  • GET /api/conversations/{id}/side — 列出主会话下已有的侧边子会话,供前端刷新后恢复 Tab
  • 多 Side Children 模型:通过 parent_conversation_idside_modefork_mode 关联,不再复用旧的单一 side_conversation_id 字段。一个主对话可以挂多个独立的侧边子会话
  • 双 Fork 策略(服务端自动选择):
    • claude / opencode / vibe(ACP backend)→ agent_fork,产品展示为“会话分叉”
    • codex(ACP backend)/ aionrs / 其他未声明 session/fork 的 ACP backend → text_snapshot,产品展示为“摘要模式”
    • OpenClaw / Nanobot / Remote / gemini legacy type 不展示侧边入口;后端对非 ACP / Aionrs 父会话直接拒绝
  • 向后兼容
    • 新 v0.2 行:创建时一次性注入上下文,不做 per-turn 重新注入
    • 旧 legacy 行(无 fork_mode):保留 per-turn enrich 路径
    • 父会话 guardrail 消息不泄漏到子会话

API 示例

POST /api/conversations/{id}/side
{
  "initial_prompt": "为什么重构后测试挂了?",
  "forked_at_msg_id": "msg_42"
}

→ { "conversation_id": "side-conv-abc123", "created": true, "fork_mode": "agent_fork" }

文件变更(18 files, +839 −16)

  • aionui-ai-agent — 暴露 ACP session fork 能力、父会话 warmup、fork_parent_session_id 传入子会话
  • aionui-api-types — 请求/响应类型、SideForkMode 枚举、agent build extra 的 fork 字段
  • aionui-conversation — POST/GET /side 路由、多 side child 创建/恢复、fork 策略选择、snapshot 注入、legacy enrich 兼容
  • aionui-db — 新增 list_side_children 查询,按 parent_conversation_id / side_mode 恢复侧边子会话
  • 测试/Mock — 补齐 repository mock、ACP build extra fixtures、fork 策略单测、stream relay 测试适配

Test plan

  • cargo check -p aionui-conversation -p aionui-api-types
  • cargo build -p aionui-app
  • 集成测试:创建 side child → 验证 fork_mode → 列出 side children → 删除 parent → 验证级联删除
  • 旧 legacy 行(无 fork_mode)仍走 per-turn enrich 路径

配合 AionUI 前端 PR:iOfficeAI/AionUi#3196

Expose POST /api/conversations/:id/side to fork ephemeral side threads
with hidden guardrail context, optional initial prompt, and cascade
delete of ephemeral children when the parent is removed.
@taekchef taekchef force-pushed the feat/side-conversation branch from 9e5c92e to 0a5aa4e Compare June 4, 2026 15:52
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.

1 participant