Skip to content

fix(ai): 修复 Orchestrator 模式多轮对话的 5 个关联 bug#250

Merged
hrygo merged 4 commits into
mainfrom
fix/249-orchestrator-multi-turn-bugs
Feb 17, 2026
Merged

fix(ai): 修复 Orchestrator 模式多轮对话的 5 个关联 bug#250
hrygo merged 4 commits into
mainfrom
fix/249-orchestrator-multi-turn-bugs

Conversation

@hrygo

@hrygo hrygo commented Feb 17, 2026

Copy link
Copy Markdown
Owner

Summary

修复 Orchestrator 模式多轮对话的 5 个关联 bug:

  1. Block 未创建 - executeWithOrchestrator 添加 block 创建逻辑
  2. UserID 丢失 - 通过 OrchestratorContext 从 context 提取 userID
  3. 粘性路由失效 - 添加 isRelatedToLastIntent 放宽粘性路由条件
  4. 标题重复生成 - 随问题1修复自动解决
  5. 上下文未复用 - executeWithOrchestrator 构建 history 并注入 context

架构亮点

采用面向未来的设计:通过 OrchestratorContext 在 Go context 中传递参数,未来扩展无需修改接口签名。

Request Context (user_id, history, conversation_id, block_id)
    ↓
Handler Layer: WithOrchestratorContext(ctx, &OrchCtx{...})
    ↓
Orchestrator: 从 ctx 提取 history
    ↓
ExpertRegistry: 从 ctx 提取 userID → factory.CreateParrot(expert, uid)

新增文件

  • ai/context/orchestrator.go - OrchestratorContext 定义和 helper 函数

Resolves #249

Test plan

  • 测试多轮对话:先问"最近记了什么笔记",再问"总结这些笔记"
  • 验证第二轮对话有 block_id
  • 验证 BM25 搜索能正确使用 userID
  • 验证粘性路由对相关意图生效
  • 验证历史上下文被正确传递

🤖 Generated with [://claude.com/claude-code)Claude Code](https

hotplex-ai and others added 4 commits February 17, 2026 09:53
- 问题1: executeWithOrchestrator 添加 block 创建逻辑
- 问题2: 通过 OrchestratorContext 从 context 提取 userID
- 问题3: 添加 isRelatedToLastIntent 放宽粘性路由条件
- 问题4: 随问题1修复自动解决
- 问题5: executeWithOrchestrator 构建 history 并注入 context

采用面向未来的架构:通过 context 隐式传递参数,未来扩展无需修改接口签名。

Resolves #249

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 合并重复的 extractIntent 函数到 agent 包
- GetHistory 返回空切片而非 nil
- 移除 intentKeywords 重复项
- strings.Index 替换为 strings.Cut

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DRY 违规修复:
- 合并 parseInabilityReport 到 agent.ParseInabilityReport

动态关键词加载:
- 在 ExpertRegistry 接口添加 GetIntentKeywords 方法
- ChatRouterWithMetadata 支持 IntentKeywordProvider 依赖注入
- 从专家配置动态加载关键词,fallback 到硬编码

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- memo.yaml: 添加 sticky routing 关键词(总结、详细内容、相关等)
- schedule.yaml: 添加 sticky routing 关键词(修改、取消、时间等)
- chat_router.go: 更新 intentKeywords fallback 与配置文件保持一致

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hrygo hrygo merged commit 4e73553 into main Feb 17, 2026
9 checks passed
@hrygo hrygo deleted the fix/249-orchestrator-multi-turn-bugs branch February 17, 2026 02:46
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.

fix(ai): 修复 Orchestrator 模式多轮对话的 5 个关联 bug

2 participants