oudecheng
fc3a95b152
feat: 异步子代理 v8 实现与 /stop 取消流程修复
...
后端核心实现:
- 新增 wait_coordinator:释放/重获取 serial_lock 的 in-tool waiting 模式,替代旧的 break-exit 方案
- 新增 wait_for_subagents 工具:select! 等待子代理完成/用户消息/超时,支持 try_drain 批量消费
- task 工具异步 spawn 路径:CancellationToken 注册表 + RAII guard + Semaphore 并发限流
- process exit 安全检查:pending 子代理存在时抑制 ExecutionCompleted
- 崩溃恢复:启动时标记 running->interrupted,history 加载时对账占位
/stop 取消流程修复:
- wait_coordinator select! 添加 cancel 分支,完整清理状态
- ToolContext 注入 cancel_rx(watch::Receiver clone)
- agent_loop 工具执行 select! 对 wait 工具跳过竞速,防止 drop coordinator 清理逻辑
- 子代理完成状态通过 execution_completed metadata 传播
存储层:
- pending_subagents 表 + 条件 UPDATE
- mark_all_running_as_interrupted 崩溃恢复
2026-08-13 22:12:20 +08:00
oudecheng
29060315a3
feat(observability): 端到端可观测性整改,修复 trace_id 断链与指标配对
...
- 传播 trace_id:BusToolCallEmitter/SubAgentEmitter/processor 全链路设置
- AgentEnd 配对:补发 5 个 cancel/defensive 路径,闭合 AgentStart 指标
- LLM 计时修正:attempt_start 移入 retry 循环,排除退避等待时间
- /metrics auth:非 loopback 部署时纳入 Bearer token 校验
- recorder 复用:OnceLock 缓存 PrometheusHandle,热重启后不再返回 503
- 结构化日志:新增 tracing_ctx + JSON 日志格式支持
2026-08-12 08:26:42 +08:00
oudecheng
3e97ed903c
feat(mcp): 为 MCP 工具调用增加超时保护,默认 5 分钟
...
在 McpToolWrapper 适配层用 tokio::time::timeout 包裹 call_tool,防止外部 MCP server 挂起导致 agent loop 无限阻塞。超时时间通过 config.mcp_tool_timeout_secs 配置(默认 300 秒,0=不超时),前端 McpTab 设置页提供输入框。
2026-08-11 21:53:07 +08:00
oudecheng
7b459b8ca1
feat(config): 压缩算法关键参数暴露到设置页面
...
将 4 个压缩参数(threshold_ratio、llm_compaction_threshold_ratio、
truncate_max_tokens、preserve_count)从硬编码提取到 config.json 顶层
compaction 节,前端新增 CompactionTab 供用户调整。
后端:
- config: 新增 CompactionConfig 结构体,Config 新增 compaction 字段
- context_compressor: 4 个参数内聚到 ContextCompressor 实例字段;
新增 with_compaction_config() 构造函数和 truncate_tool_results() 方法;
对用户配置做防御性 clamp(ratio ∈ [0.1,1.0],整数 ≥ 1)
- agent_loop: 调用 compressor.truncate_tool_results() 实现零参数耦合
- agent_factory: 新增 build_compressor() 方法,in-loop 与 sync 兜底
两条压缩路径共用同一套用户配置
- session: with_factories 改用 agent_factory.build_compressor(),修复
sync 压缩路径忽略用户配置的 P0 问题
前端:
- types: 新增 CompactionConfig 接口,TabId 新增 'compaction'
- 新建 CompactionTab.tsx,4 个 number input 分两组 SectionCard
- constants + ConfigPage: 注册"上下文压缩" Tab(Archive 图标)
清理:删除无调用方的 from_provider_config/from_runtime_config/with_config
方法及 DEFAULT_THRESHOLD_RATIO/LLM_COMPACTION_THRESHOLD_RATIO 常量。
测试:context_compressor 18 + session 31 + agent_loop 42 全通过。
2026-08-06 11:03:56 +08:00
oudecheng
cda14360af
chore: 建立工程化基线(rustfmt + clippy + CI + eslint + prettier)
...
配置:
- rustfmt.toml: 固化 max_width=100 / 4 空格缩进,cargo fmt 全量格式化
- Cargo.toml: 配置 [lints.rust] 与 [lints.clippy] 渐进式规则
- .github/workflows/ci.yml: Rust(fmt+clippy+test) + 前端(eslint+tsc+test) 双平台 CI
- Makefile: 新增 check/fmt/fix 目标,clippy 对齐 --all-targets --all-features
- web: eslint flat config + prettier 配置 + package.json 脚本与依赖
- src/main.rs: loop→while 修复 clippy::never_loop
对抗性审查发现并修复:
- eslint 缺 caughtErrorsIgnorePattern 导致 catch(_) 误报为 error
- 前端 lint 未接入 CI,现已补上 Lint 步骤
- Makefile 与 CI 的 clippy flags 不一致,已对齐
2026-08-03 23:24:02 +08:00
oudecheng
a825b10c48
feat(model): 主 agent 支持会话级模型覆盖
...
新增 ModelSelectionStore 存储 session_id -> (provider, model) 映射,职责单一,仅依赖 std,不引入业务模块耦合。
AgentFactory::create 中按链式覆盖应用模型配置: 专家 frontmatter 覆盖 -> 用户手动选择覆盖(最高优先级)。
HTTP API: POST /api/session/select-model 设置/清除用户模型覆盖(校验 provider/model 存在性); GET /api/session/selected-model 读取当前 session 的用户覆盖(与 experts/selected 对称)。
在 build_session_manager 系列函数中创建并注入 ModelSelectionStore,GatewayState 持有 Arc<ModelSelectionStore> 供 HTTP handler 访问。
2026-07-30 23:24:51 +08:00
oudecheng
dc9211548a
feat(model): 专家和子代理支持独立配置 provider/model
...
- 新增 ModelResolver 解析器,按 frontmatter 中的 provider/model 名覆盖基础 LLMProviderConfig
- Expert/SubagentDef 数据结构新增 provider/model 字段,frontmatter 解析与渲染支持往返
- AgentFactory 和 DefaultSubAgentRuntime 持有 ModelResolver,在创建 agent 时解析模型覆盖
- HTTP API 新增 /api/model-options 端点,ExpertResponse/Create/Update 和 SubagentUpdateRequest 支持 provider/model
- update_expert/update_subagent 支持 provider/model 字段写回 frontmatter
- 保持架构解耦:ModelResolver 位于 config 底层,不引入新的跨模块依赖
2026-07-30 22:44:10 +08:00
oudecheng
12f1094426
feat(capability): 新增 CapabilityPolicy 统一策略模型并集成至专家/子代理/技能
...
- domain: 定义 CapabilityPolicy(allowed/denied skills/tools)统一策略结构
- experts: 专家支持 capability 字段,新增 update_expert 写回 EXPERT.md
- skills: SkillRuntime 暴露 capability 过滤接口
- tools/task: SubagentDef 增加 capability 字段,SubagentRuntime 新增 update_subagent 写回 SUBAGENT.md,工具集按 capability 过滤
- agent_factory: 按 capability 构建专家/子代理工具集(白名单交集 + 黑名单扣除)
2026-07-30 16:53:30 +08:00
oudecheng
cea4bd3cfb
feat: 子代理支持数据驱动的工具过滤(白名单+黑名单),删除内置 explore
...
SUBAGENT.md frontmatter 新增 denied_tools 黑名单字段,启用已有的 allowed_tools 白名单;新增 ToolRegistry::only 白名单方法;抽取 build_subagent_tools_registry(白名单→黑名单→depth 兜底);安全修复:resume 在 def 失踪时拒绝恢复而非降级为完整工具集(避免权限提升);depth 阈值改为引用 max_nesting_depth 配置;SubagentWithStatus 暴露工具字段供前端只读展示;删除内置 explore 子代理及专属 explore_max_execution_secs 配置(全栈清理);新增 23 个测试覆盖过滤矩阵、frontmatter 解析、状态投影
2026-07-09 14:42:38 +08:00
oudecheng
4329cfbbe9
feat: 统一路径显示格式,确保跨平台兼容性;重构系统提示词提供者构建逻辑
2026-07-07 09:19:58 +08:00
oudecheng
9d7c1f2e52
feat: 集成专家提示词到网关配置、依赖注入与HTTP API
...
- config: 新增 ExpertsConfig,默认 sources=[user,project], enabled=true
- AgentFactory: 新增 experts 字段,providers 顺序为 Agent→Skill→Expert→Subagent→Todo
- GatewayState: 持有 Arc<ExpertRuntime>,from_config 中初始化
- runtime: build_session_manager_with_sender 接收 experts 参数
- 路由: 注册 7 个专家 API (list/toggle/create/update/delete/selected/select)
- http: 实现 7 个处理器,支持专家 CRUD 与 session 级选择
- session/cli: 测试便利构造器与 empty_config/build_config 补齐 experts 字段
2026-07-06 18:07:33 +08:00
oudecheng
8d30ccd020
feat: 新增子代理管理API,支持获取子代理列表和切换子代理状态
2026-07-06 14:41:30 +08:00
oudecheng
5ceafb1fd7
feat: 添加配置应用诊断日志,便于排查 AgentFactory 实例与工具列表
2026-07-03 16:33:01 +08:00
oudecheng
4fabbe47e9
feat: 增强MCP集成,支持配置路径和连接重试机制
2026-06-30 10:46:33 +08:00
oudecheng
2607ca4aa4
refactor(task): 优化任务工具和子代理深度管理
...
- 在 AgentContext 中新增 task_id 字段,用于标识当前智能体任务 ID
- 统一 TaskTool 构造函数,使用 Option<u32> 表示最大嵌套深度限制
- 调整子代理工具注册,适配新的 TaskTool 构造函数
- 修改子代理运行时创建逻辑,传递并设置 task_id 和 parent_task_id
- 删除重复的 task_id 提取函数,改用传递参数进行关联
- 深度校验改为判断 Option,支持无深度限制和有限层数
- 增强子代理间的任务层级关联,正确传递 parent_task_id 元数据
2026-06-18 11:41:40 +08:00
oudecheng
879f5f243a
feat(task): 增加子代理最大嵌套深度支持,更新相关文档和提示
2026-06-17 17:55:22 +08:00
oudecheng
631c61fea2
feat(agent): 支持子代理最大嵌套深度控制
...
- 在配置结构体中新增 max_nesting_depth 字段,设置子代理最大嵌套深度
- 在 AgentFactory、todo_read、todo_write 等处初始化 nesting_depth 字段为 0
- 允许 Task 工具注册,使用 max_nesting_depth 控制子代理嵌套层数
- SubAgentRuntimeConfig 新增 max_nesting_depth 配置项,默认值为 1
- TaskTool 新增 max_nesting_depth 字段和带深度限制的构造函数
- 任务执行时增加嵌套深度校验,超过最大深度返回错误提示,防止无限递归创建子代理
2026-06-17 14:43:55 +08:00
oudecheng
7626ba2d2f
feat(gateway): 添加待办事项读取功能
...
- 引入 TodoReadTool 工具支持读取当前对话的待办事项列表
- 实现从内存或SQLite数据库读取待办事项的功能
- 添加内存回填机制确保数据一致性
- 在ToolRegistryFactory中注册新的待办事项读取工具
- 更新会话初始化逻辑以传递待办事项存储依赖
- 添加完整的单元测试验证各种读取场景
2026-06-15 15:33:43 +08:00
oudecheng
24bbd5f8c9
feat: 子代理 todo 列表支持 — 进入子代理视图时显示子代理的待办
...
- SubAgentEmitter 添加 todo_write 持久化(照搬 BusToolCallEmitter 模式)
- DefaultSubAgentRuntime 加 store 字段,透传给 emitter
- Command::ListTodos 加 task_id 参数
- list_todos handler: 当 task_id 存在时,scope_key = sub:{parent}:{task_id}
- 前端: 子代理视图下自动带 task_id 请求子代理的 todo
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 18:01:57 +08:00
oudecheng
881fcace47
feat: 添加 todo_write 工具,支持全量替换和增量合并两种模式
...
- Tool: 纯内存实现 (Arc<RwLock<HashMap>>),零 DB 依赖,解耦持久化
- 状态机: pending → in_progress → completed/cancelled,单 in_progress 约束
- merge=false: 全量替换模式(默认)
- merge=true: 增量更新模式,只传变更的项,其余保留
- 隔离: scope_key = topic_id.unwrap_or(session_id),topic 和子代理隔离
- 持久化: TodoRepository trait + SessionStore SQLite 实现,在 Session 拦截器层完成
- 前端推送: WsOutbound::TodoList 事件
- Prompt: TodoPromptProvider 中文指令,子代理模板也包含
- 测试: 16 个单元测试,全部通过
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 14:19:07 +08:00
oudecheng
4cb26b5b67
feat: 子智能体任务消息查看,实时广播工具调用事件
...
- 新增 LoadTaskMessages 命令,加载子智能体任务的历史消息
- SubAgentEmitter 通过 MessageBus 实时广播子智能体工具调用
- 前端新增子智能体视图,支持导航进入/退出子智能体会话
- 外部渠道过滤子智能体事件,避免推送到飞书/微信
- ToolCall/ToolResult 新增 subagent_task_id 字段
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 11:15:38 +08:00
oudecheng
644f5f9132
feat: 子代理继承主代理的 MCP 工具
...
- 为 McpToolWrapper 添加 Clone trait,支持工具实例复用
- 修改 build_subagent_tools 方法,支持传入 MCP 工具列表
- 调整 runtime 构建顺序:先等待 MCP 连接,再将 MCP 工具传递给子代理
子代理现在可以自动使用主代理配置的 MCP 工具(如 filesystem、fetch 等)。
2026-05-26 11:53:40 +08:00
oudecheng
86d48a3ec0
feat: 实现自定义子代理加载功能
...
- 添加 SubagentCatalog::discover() 方法,支持从文件系统加载自定义子代理
- 支持 ~/.picobot/subagents/ 和 ./.picobot/subagents/ 两个目录
- 项目级定义可覆盖用户级定义
- 支持 YAML frontmatter + body 格式解析
- 修复 Windows 换行符兼容性问题
- 移除未使用的 read_only 字段
- 实现 TaskTool 动态 schema,子代理类型列表从运行时获取
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 11:56:44 +08:00
9ae2813c20
feat: 添加子代理配置,支持自定义子代理定义和运行时管理
2026-05-24 21:35:36 +08:00
4605c2dad3
feat: 重构 MCP 配置,支持 mcpServers 字段,优化工具注册和连接管理
2026-05-24 10:00:25 +08:00
ef7e899584
feat: 集成 MCP (Model Context Protocol),支持 Stdio 和 HTTP 传输方式,优化工具注册和连接管理
2026-05-23 23:22:36 +08:00
cbb384a4e6
feat: 添加 MCP (Model Context Protocol) 支持,包含客户端管理器和工具适配器
2026-05-23 22:52:36 +08:00
b6f2de053d
refactor: 移除会话重置逻辑中的 reset_cutoff_seq 字段,优化会话管理和历史压缩逻辑
2026-05-23 18:38:34 +08:00
b4ef56803f
feat: 添加内存维护配置,优化记忆整理逻辑和限制
2026-05-23 16:05:11 +08:00
oudecheng
49475783a2
feat: 添加子智能体支持到保存话题和会话功能,优化数据持久化
2026-05-20 17:52:46 +08:00
oudecheng
fc628239a4
feat: 添加技能索引支持到子代理系统提示词构建,优化提示词组合逻辑
2026-05-20 15:34:34 +08:00
831832664d
feat: 重构会话管理逻辑,添加获取当前话题的方法,简化命令处理中的会话获取逻辑
2026-05-16 20:19:49 +08:00
6b5d45e3a5
feat: 添加探索类型最大执行时间配置,优化子代理任务执行逻辑
2026-05-16 17:05:03 +08:00
bee1a39a06
feat: add task management tool with subagent support
...
- Introduced `TaskConfig` struct to manage task-related configurations.
- Implemented `TaskTool` for creating and managing subagents for complex tasks.
- Added `TaskSession` and `TaskRepository` for handling task sessions and persistence.
- Created `DefaultSubAgentRuntime` to execute tasks with timeout and history support.
- Enhanced `ToolContext` to include `subagent_description` for better context tracking.
- Implemented error handling for task execution and session management.
- Updated `ToolRegistryFactory` to register task tools conditionally based on configuration.
- Added prompt builders for subagent tasks to improve interaction clarity.
2026-05-16 16:12:28 +08:00
9bf57c1132
feat: 移除任务管理相关功能,简化工具配置和依赖
2026-05-16 09:08:40 +08:00
020b7aa77a
feat: 添加任务管理功能,支持创建和恢复子代理任务,优化任务执行和状态管理
2026-05-16 08:50:15 +08:00
oudecheng
e709773464
feat: 添加话题管理功能,支持切换和持久化话题历史
2026-05-15 15:28:07 +08:00
oudecheng
86ba3b447e
feat: 添加会话管理功能,支持会话过期清理;引入 session_ttl_hours 配置项以控制会话存活时间
2026-05-14 15:29:37 +08:00
oudecheng
1c1efcabf4
feat: 移除冗余的 provider_config 字段,优化 AgentFactory 和 Session 的构造逻辑
2026-05-13 15:41:52 +08:00
oudecheng
a06fceaf0c
feat: 添加系统提示词提供者,支持动态注入和组合多个提示词源
2026-05-13 14:55:50 +08:00
daec690f59
feat: 更新会话配置,重命名 session_ttl_hours 为 chat_history_ttl_hours,并调整相关逻辑以支持聊天历史过期管理
2026-05-10 19:29:55 +08:00
33e6b78267
feat: 添加工具配置示例,支持工具启用/禁用功能;更新调度器管理工具描述以支持标准 cron 语法
2026-05-10 13:57:47 +08:00
260266b90f
feat: 添加会话消息发送工具,支持文本和附件的发送,优化消息发送逻辑
2026-05-02 09:15:36 +08:00
716d92a618
feat: 引入 AgentRuntimeConfig,重构相关模块以支持运行时配置
...
Co-authored-by: Copilot <copilot@github.com>
2026-04-30 22:34:22 +08:00