Commit Graph

109 Commits

Author SHA1 Message Date
朱潮
c2f7148f98 增加环境变量到pre prompt 2026-03-31 14:37:20 +08:00
朱潮
e13405ba29 shell_env support 2026-03-24 00:12:19 +08:00
朱潮
c27270588f 增加取消推理 2026-03-16 22:22:39 +08:00
朱潮
32fd8c8656 shell_env支持 2026-03-16 13:31:59 +08:00
朱潮
85cc57ce1a aupdate from_v2_request 新增 model_name、model_server、api_key 三个可选参数 2026-03-06 12:53:16 +08:00
朱潮
8264257ab6 现在 from_v2_request 的 model_name 和 model_server 优先级逻辑为:
1. 最高优先级:generate_cfg 中的 model / model_server(需不为空且不等于 whatever)
  2. 回退:bot_config 中的值(原有逻辑)
2026-03-06 12:47:33 +08:00
朱潮
b6b821c9bb bug fix 2026-03-04 14:30:44 +08:00
朱潮
f7773a93e1 Merge branch 'upgrade/deepagents-0.4.4' 2026-03-04 14:08:51 +08:00
朱潮
52d8161b0e 修改确保 max_length 永远不会是 None 2026-03-04 14:08:26 +08:00
朱潮
9215f8236d 🐛 fix: 修复 Mem0 连接池耗尽和 LLM 参数透传问题
- mem0_manager: 添加 _cleanup_mem0_instance 方法,在缓存移除实例时显式释放数据库连接,避免等待 GC 导致连接池耗尽
- deep_assistant: 根据 model_provider 过滤不支持的参数,Anthropic 不支持 OpenAI 特有参数如 n、presence_penalty 等

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-04 10:11:44 +08:00
86b38262fa fix(memory): handle Mem0 get_all response format with results key
Mem0's get_all() returns data in format {"results": [...]}, not a direct list.
Also, agent_id is at the top level of each memory, not in metadata.

Changes:
- Add _extract_memories_from_response() to handle both new and old response formats
- Add _check_agent_id_match() to check agent_id at both top-level and in metadata
- Update get_all_memories, delete_memory, delete_all_memories to use new helpers

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:28:39 +00:00
autobee-sparticle
572374b297
fix(memory): handle Mem0 get_all returning string or dict items (#11)
Mem0's get_all() method may return a list containing either strings
(older version format) or dictionaries (newer version format). This
fix adds proper type checking to handle both cases gracefully.

- get_all_memories: Skip string items, only process dict items
- delete_memory: Add type checking before accessing dict methods
- delete_all_memories: Add type checking before accessing dict methods

Fixes: 'str' object has no attribute 'get' error

Co-authored-by: zhuchao <zhuchaowe@163.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 22:02:59 +09:00
a1f60a7024 fix: 修复 get_all_memories 调用时 config 为 None 导致的错误
问题:当调用 get_all_memories API 时,没有传递 config 参数,
导致 _create_mem0_instance 中的 config 为 None,
调用 config.get_custom_fact_extraction_prompt() 时抛出 AttributeError。

修复:添加 config 的空值检查,只在 config 存在时才添加 custom_fact_extraction_prompt。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 12:39:45 +00:00
朱潮
5b29e866f2 现在 v1 和 v2 接口都支持传递额外参数了 2026-03-02 20:01:43 +08:00
朱潮
f72a53462a Merge branch 'master' of https://github.com/sparticleinc/catalog-agent 2026-03-02 16:07:10 +08:00
朱潮
4a534163d5 skill.md文件长度限制解除 2026-03-02 12:55:39 +08:00
朱潮
03078a2077 移除虚拟文件夹 2026-03-02 12:17:19 +08:00
朱潮
61c8186b55 upgrade/deepagents-0.4.4 2026-03-02 02:27:42 +08:00
朱潮
3ce0b6a9f8 fix: update CustomSkillsMiddleware.before_agent signature
Add missing 'config' parameter to match new SkillsMiddleware API.
2026-03-02 01:37:30 +08:00
朱潮
a0b6e4cc7f feat: upgrade deepagents 0.4.3 and deepagents-cli 0.0.25
- Replace ShellMiddleware with LocalShellBackend
- Update AgentMemoryMiddleware to MemoryMiddleware with new signature
- Update CustomSkillsMiddleware to use new SkillsMiddleware signature
- Add LocalContextMiddleware for local context
- Update CompositeBackend to use routing
- Update dependencies: langgraph-checkpoint-postgres to 3.0.4

Breaking Changes:
- agent/deep_assistant.py: Major refactoring to adapt to new deepagents API
  - pyproject.toml: Version bump
    - deepagents: 0.2.8 -> 0.4.3
    - deepagents-cli: 0.0.11 -> 0.0.25
  - langgraph-checkpoint-postgres: 2.0.25 -> 3.0.4 (for compatibility with langgraph-checkpoint 3.x)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-02 01:29:58 +08:00
autobee-sparticle
108c675c3d
feat(memory): add memory management API endpoints (#10)
* chore: add .worktrees/ to .gitignore

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat(memory): add memory management API endpoints

Add new /api/v1/memory endpoints for viewing and managing user memories:
- GET /api/v1/memory - list all memories for a bot
- DELETE /api/v1/memory/{memory_id} - delete single memory
- DELETE /api/v1/memory - delete all memories for a bot

Also add delete_memory and delete_all_memories methods to Mem0Manager.

Issue: #1844

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: zhuchao <zhuchaowe@163.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 18:01:12 +09:00
朱潮
a822a2a1d1 优化空的工具调用 2026-02-23 23:23:38 +08:00
朱潮
f5c7d3ff9c on_tool_start 长度调整 2026-02-15 18:12:22 +08:00
朱潮
a493e98719 增加工具调用的日志 2026-02-15 09:48:45 +08:00
朱潮
198bb08690 修改tool 工具日志 2026-02-14 19:06:14 +08:00
朱潮
2d20c7cbba update dataset_id_str 2026-02-10 22:18:30 +08:00
朱潮
569fb3aa79 env only command enable 2026-02-10 20:07:47 +08:00
朱潮
815ad01876 add mcp dataset_ids 2026-02-10 19:00:19 +08:00
朱潮
805bd6f5d4 modify skill middleware 2026-02-10 11:53:14 +08:00
朱潮
3ec992436c add USER_IDENTIFIER 2026-02-07 15:39:20 +08:00
朱潮
c7e9f305b7 feat: 实现 Claude Plugins 模式的 Hook 机制
- 新增 agent/plugin_hook_loader.py:支持通过 .claude-plugin/plugin.json 配置 hooks 和 mcpServers
- 修改 agent/prompt_loader.py:集成 PrePrompt hooks,优先读取 skill MCP 配置
- 修改 routes/chat.py:添加 PostAgent 和 PreSave hooks
- 修改 routes/skill_manager.py:优先从 plugin.json 读取 name/description,fallback 到 SKILL.md
- 删除旧的 agent/skill_hook_loader.py
- 新增示例 skill user-context-loader,演示完整的 hooks 用法

Hook 类型:
- PrePrompt: 在 system_prompt 加载时注入内容
- PostAgent: 在 agent 执行后处理
- PreSave: 在消息保存前处理

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 20:15:54 +08:00
朱潮
e67d50b4fc rename general agent 2026-02-06 17:05:17 +08:00
朱潮
525801d7f5 update summary 2026-02-04 15:31:41 +08:00
朱潮
f1107ea35a 增加enable_thinking和enable_memory 2026-01-28 17:13:41 +08:00
朱潮
5134c0d8a6 添加环境变量 2026-01-25 21:46:02 +08:00
朱潮
3dc119bca8 refactor(mem0): optimize connection pool and async memory handling
- Fix mem0 connection pool exhausted error with proper pooling
- Convert memory operations to async tasks
- Optimize docker-compose configuration
- Add skill upload functionality
- Reduce cache size for better performance
- Update dependencies

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 19:39:12 +08:00
朱潮
0922ad084a patch 2026-01-21 13:23:11 +08:00
朱潮
99755ceab5 remove settingsetting 2026-01-21 10:38:29 +08:00
朱潮
223c63047d fix(mem0): use asyncio.run() for async call in sync embed method
在 CustomMem0Embedding.embed() 同步方法中使用 asyncio.run()
调用异步的 manager.get_model(),解决同步/异步混合调用问题。

Generated with [Claude Code](https://claude.com/claude-code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-01-20 23:03:21 +08:00
朱潮
366a64283e Added memory log 2026-01-20 21:30:32 +08:00
朱潮
f694101747 refactor: migrate from Memori to Mem0 for long-term memory
Replace Memori with Mem0 for memory management:
- Delete memori_config.py, memori_manager.py, memori_middleware.py
- Add mem0_config.py, mem0_manager.py, mem0_middleware.py
- Update environment variables (MEMORI_* -> MEM0_*)
- Integrate Mem0 with LangGraph middleware
- Add sync connection pool for Mem0 in DBPoolManager
- Move checkpoint message prep to config creation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 21:15:30 +08:00
朱潮
4d6ee6ae0c fix: pass db_url to init_global_memori
Add db_url property to MemoriManager that falls back to
CHECKPOINT_DB_URL setting, and pass it explicitly from
fastapi_app.py to ensure Memori can create sync connections.

This fixes the error "Either db_pool or db_url must be provided"
when recalling memories.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-20 08:27:34 +08:00
朱潮
456bcf50e6 refactor: move Memori initialization to fastapi_app.py
Move init_global_memori from deep_assistant.py to fastapi_app.py
lifespan function for proper application-level initialization.

This ensures Memori is initialized once at startup and closed at
shutdown, rather than checking and potentially initializing on every
agent creation.

Changes:
- fastapi_app.py: Add Memori init/close in lifespan
- deep_assistant.py: Simplify to only get memori_manager

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

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-20 00:15:21 +08:00
朱潮
455a48409d feat: integrate Memori long-term memory system
Add Memori (https://github.com/MemoriLabs/Memori) integration for
persistent cross-session memory capabilities in both create_agent
and create_deep_agent.

## New Files

- agent/memori_config.py: MemoriConfig dataclass for configuration
- agent/memori_manager.py: MemoriManager for connection and instance management
- agent/memori_middleware.py: MemoriMiddleware for memory recall/storage
- tests/: Unit tests for Memori components

## Modified Files

- agent/agent_config.py: Added enable_memori, memori_semantic_search_top_k, etc.
- agent/deep_assistant.py: Integrated MemoriMiddleware into init_agent()
- utils/settings.py: Added MEMORI_* environment variables
- pyproject.toml: Added memori>=3.1.0 dependency

## Features

- Semantic memory search with configurable top-k and threshold
- Multi-tenant isolation (entity_id=user, process_id=bot, session_id)
- Memory injection into system prompt
- Background asynchronous memory augmentation
- Graceful degradation when Memori is unavailable

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

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-20 00:12:43 +08:00
朱潮
af63c54778 db_pool 2026-01-19 23:39:04 +08:00
朱潮
f9ba3c8e51 添加聊天记录查询 2026-01-18 12:29:20 +08:00
朱潮
174a5e2059 deep_agent支持 checkpoint 2026-01-11 00:08:19 +08:00
朱潮
b93c40d5a5 merge 2026-01-08 23:10:09 +08:00
朱潮
d45079ca55 feat: 将system_prompt解析从markdown代码块改为XML标签格式
- agent_config.py: enable_thinking判断从 ```guideline 改为 <guidelines>
- fastapi_utils.py:
  - preamble解析从 ```preamble``` 改为 <preamble>
  - guidelines/tools/scenarios/terms 块解析从 markdown 格式改为 XML 标签格式
  - 移除不再使用的 parse_guidelines_text 函数

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 22:56:43 +08:00
朱潮
5a4aee91ab merge 2026-01-08 22:28:10 +08:00