16 Commits

Author SHA1 Message Date
oudecheng
46a1ca6853 refactor: 修复 3 项 P1 技术债(硬编码 URL / any 类型 / dead_code)
P1-1: 硬编码 wechat URL 抽常量统一两处
  - config/mod.rs: 定义 pub const WECHAT_DEFAULT_BASE_URL
  - cli/init.rs: import 并引用常量,消除字面量重复
  - 消除两处不一致风险(default_wechat_base_url 与 init 向导)

P1-2: ConfigPage any 类型定义具体类型(8 处)
  - types.ts: 新增 FeishuChannelConfig/WechatChannelConfig/ChannelConfig/
    SchedulerJobConfig 类型;jobs?: any[] → SchedulerJobConfig[];
    channels: Record<string, any> → Record<string, ChannelConfig>
  - api/config.ts: 新增 RestartResponse 类型,data: any → RestartResponse
  - ConfigPage.tsx: catch (e: any) ×2 → catch (e: unknown) + 类型守卫;
    as any → as SchedulerConfig['misfire_policy'];
    Record<string, any> → Partial<ChannelConfig>;(ch: any) → (ch: ChannelConfig)

P1-3: dead_code 18 处逐一审查清理
  - 删除 10 处未使用函数/struct(YAGNI 原则):
    context_compressor.rs (into_messages, is_tool_round)
    agent_loop.rs (EmptySkillProvider struct + impl)
    memory_maintenance.rs (run_for_scope)
    session.rs (try_start/finish_background_compaction)
    session_history.rs (try_start/finish_background_compaction)
    tool_registry_factory.rs (shell_session_manager)
    task/runtime.rs (effective_allowed_tools)
  - 保留 8 处 serde 反序列化字段(删除会破坏 JSON 反序列化):
    feishu.rs/openai.rs/anthropic.rs/skills/mod.rs/task/runtime.rs
2026-07-08 14:51:42 +08:00
oudecheng
f3365f8d3a feat: 添加 HistoryUnit 解析单元测试,验证系统守卫和工具调用的处理逻辑 2026-07-03 10:19:33 +08:00
oudecheng
51e06c8f73 feat: 实现两段历史压缩的同步处理,替换会话的活动历史记录 2026-07-03 09:52:45 +08:00
oudecheng
95cf152ab9 fix(agent): 修复工具调用消息序列的完整性问题
- 在历史压缩时,移除保留消息中不完整的工具调用序列,防止API 400错误
- 压缩后对当前历史消息再次进行工具调用序列清理,确保消息序列有效性
- OpenAI请求构建中,增加位置感知的工具调用和结果配对验证
- 跳过含有不完整工具调用序列的助手消息,避免发送非法请求
- 剥离不完整助手消息的工具调用字段,作为普通助手消息序列化
- 跟踪并警告不完整工具调用序列和被跳过的消息索引
2026-06-23 08:44:48 +08:00
oudecheng
90228a4d49 feat: 更新 GetCurrentSessionCommandHandler,添加系统提示词提供者支持并优化令牌估算逻辑 2026-05-19 18:29:32 +08:00
oudecheng
3c2650824c feat: 更新令牌估算逻辑,使用 JSON 序列化以匹配实际请求大小,并在当前话题处理器中添加令牌估算 2026-05-19 17:05:04 +08:00
531e72d24f feat: 添加图像处理预算和估算逻辑,优化消息内容构建,支持图像媒体引用
Co-authored-by: Copilot <copilot@github.com>
2026-05-01 21:22:07 +08:00
716d92a618 feat: 引入 AgentRuntimeConfig,重构相关模块以支持运行时配置
Co-authored-by: Copilot <copilot@github.com>
2026-04-30 22:34:22 +08:00
fa3354db9c feat: add context_window_tokens to model configuration and update related logic
- Introduced context_window_tokens in ModelConfig and LLMProviderConfig structs.
- Updated context window estimation logic in ContextCompressor to use context_window_tokens.
- Modified tests to accommodate new context_window_tokens field.
- Refactored memory maintenance logic into a new memory_maintenance.rs file for better organization.
- Ensured backward compatibility by providing default values where necessary.

Co-authored-by: Copilot <copilot@github.com>
2026-04-28 11:29:06 +08:00
73dab09bfe Refactor code for improved readability and consistency
- Adjusted formatting and indentation in various files for better clarity.
- Consolidated multi-line statements into single lines where appropriate.
- Enhanced error handling messages for better debugging.
- Added a new InboundProcessor struct to handle inbound messages more effectively.
- Updated test cases to ensure they align with the new code structure.
2026-04-28 10:33:31 +08:00
88e1bfd9f2 feat: 移除配置中的上下文摘要字符限制,优化摘要预算计算
Co-authored-by: Copilot <copilot@github.com>
2026-04-26 20:47:58 +08:00
3045a6b596 feat: Enhance ChatMessage with system context and background compaction
- Added `system_context` field to `ChatMessage` for better message context handling.
- Introduced constants for system context prompts in `message.rs`.
- Updated `Session` to manage background history compaction, including methods to start and finish compaction.
- Implemented logic to schedule background compaction after message processing in `SessionManager`.
- Enhanced database schema to support new `system_context` field in messages.
- Added functionality to compact active history, preserving system messages and summaries.
- Updated tests to validate new compaction logic and ensure message integrity.
- Removed unused functions and cleaned up code in various modules for better maintainability.

Co-authored-by: Copilot <copilot@github.com>
2026-04-26 09:31:13 +08:00
3792472b83 feat: 调整工具结果和上下文摘要字符限制,优化性能 2026-04-25 16:09:19 +08:00
4b74fabb98 feat: 添加字符计数和文本截断功能,增强文本处理能力 2026-04-24 14:34:06 +08:00
f3f369b329 feat: add llm_timeout_secs to provider configuration and implement timeout handling
- Introduced llm_timeout_secs in ProviderConfig and LLMProviderConfig to specify timeout for LLM requests.
- Updated OpenAIProvider and AnthropicProvider to utilize the timeout setting when creating HTTP clients.
- Enhanced error handling for API responses to include timeout information.
- Modified SessionManager to support agent-specific provider configurations, allowing for more flexible agent management.
- Added tests to verify the correct behavior of timeout settings and agent task validation.
2026-04-23 09:23:15 +08:00
c971bc3639 feat: 添加上下文压缩功能,优化消息历史管理和工具调用日志记录 2026-04-12 18:38:38 +08:00