oudecheng
1019dbe8cc
refactor(code-quality): 清理 clippy 存量告警(unwrap/clone/redundant 等)
...
- 移除无用克隆与冗余引用,减少不必要内存分配
- 规范 unwrap/expect 使用,修复可提前失败路径
- 修复 anthropic provider llm_timeout_secs 死代码并补全超时日志
- cargo fmt 统一格式
2026-08-16 23:22:22 +08:00
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
c27efedb6c
feat(capability): 扩展 CapabilityPolicy 支持子代理黑白名单
...
- domain: CapabilityPolicy 新增 allowed_subagents/denied_subagents 字段及 check_subagent_allowed 方法
- experts: 专家 frontmatter 解析/渲染支持子代理策略字段
- task/runtime: spawn/resume 双路径校验父代理子代理策略;新增 update_subagent 写回 SUBAGENT.md(与 update_expert 对称);新增 SubagentPromptProvider 按专家策略过滤子代理索引
- task/runtime: 子代理自身 capability 作为孙代理的 parent_capability 透传(ToolContext),保持解耦
- traits: ToolContext 新增 parent_capability 字段
- agent_factory: 主 agent 注入 expert_capability 到 ToolContext
安全:策略不通过即拒绝(与 def 不可用即拒绝范式一致),防止 LLM 通过选择被禁子代理绕过限制;max_nesting_depth 兜底防递归不可被 def 覆盖。
2026-07-30 17:37:29 +08:00
oudecheng
606fcbcd29
feat(agent): 注入并传递 tool_call_id 实现任务与工具调用精准关联
...
- 在 agent_loop 执行上下文中注入 tool_call_id,确保执行时传递该字段
- 在 agent_factory、ws、todo_read、todo_write 等多处构造对象时添加 tool_call_id 字段初始化
- 扩展协议定义及序列化,支持 tool_call_id 字段传递
- 在工具调用任务运行时传递 tool_call_id,便于事件追踪和层级关联
- 在前端 useChat hook 增加 tool_call_id 关联逻辑,实现 task_started 事件精准匹配和跳转
- 增加 pendingTaskNavs 缓存处理,解决 task_started 事件先于 tool_call 到达的顺序问题
- 调整消息渲染逻辑,根据 tool_call_id 进行优先匹配,提升用户交互体验
2026-06-22 10:22:36 +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
e506ffd539
feat(agent): 支持子孙智能体的父任务链路传递
...
- 在 agent_factory 和子代理相关结构体中新增 parent_task_id 字段
- 协议层序列化、反序列化及 WebSocket 适配器支持 parent_task_id 信息传递
- todo_read 与 todo_write 工具添加 parent_task_id 以保持任务层级一致
- 在 DefaultSubAgentRuntime 中实现从 session_id 提取 parent_task_id 的逻辑
- 子智能体创建孙智能体时,正确设置并传递 parent_task_id 元数据
- 前端 useChat 钩子过滤孙智能体的 TaskStarted 事件,避免视图串扰
2026-06-18 11:30:47 +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
1c6ee160e5
feat: 添加父话题 ID 支持,优化子智能体任务管理和会话关联
2026-05-20 18:11:16 +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
d35e89a44c
#
2026-04-22 06:57:22 +08:00
d5b6cd24fc
feat(tools): add SchemaCleanr for cross-provider schema normalization
...
- Add SchemaCleanr with CleaningStrategy enum (Gemini, Anthropic, OpenAI, Conservative)
- Support cleaning JSON schemas for different LLM provider compatibility
- Add $ref resolution, anyOf/oneOf flattening, const-to-enum conversion
- Add read_only, concurrency_safe, exclusive methods to Tool trait
- Add comprehensive unit tests for all schema cleaning features
2026-04-07 23:41:20 +08:00
9834bd75cf
feat: add calculator tool and integrate with agent loop
...
- Introduced a new CalculatorTool for performing various arithmetic and statistical calculations.
- Enhanced the AgentLoop to support tool execution, including handling tool calls in the process flow.
- Updated ChatMessage structure to include optional fields for tool call identification and names.
- Modified the Session and SessionManager to manage tool registrations and pass them to agents.
- Updated the OpenAIProvider to serialize tool-related message fields.
- Added a ToolRegistry for managing multiple tools and their definitions.
- Implemented tests for the CalculatorTool to ensure functionality and correctness.
2026-04-06 23:43:45 +08:00