Commit d778dbb8 by sunqi02

refactor: 删除不再使用的文件和代码,优化项目结构

1 parent 6d1c3dc8
import sqlite3
conn = sqlite3.connect("dev.db")
cur = conn.cursor()
cur.execute("SELECT id, agent_id, position_id, created_at FROM ai_agent_positions WHERE id = ?", (10,))
before = cur.fetchall()
print("BEFORE:", before)
cur.execute("DELETE FROM ai_agent_positions WHERE id = ?", (10,))
print("rows_deleted:", cur.rowcount)
conn.commit()
cur.execute("SELECT id, agent_id, position_id, created_at FROM ai_agent_positions WHERE id = ?", (10,))
after = cur.fetchall()
print("AFTER:", after)
conn.close()
# 会议纪要
**【会议主题】**:优加二手车平台业务模式、财务合规与运营策略对齐会
**【会议日期】**:[未提及]
**【参会人】**:说话人 0、说话人 1、说话人 2、说话人 3、说话人 4、说话人 5
**【缺席人】**:[未提及]
**【本次会议要点】**
1. 确定优加与广联体外合作模式:优加负责签单与确认收入,广联提供资金与服务。
2. 明确二手车税务逻辑:按销售额0.5%简易计税,收入确认以实际售出收款为准。
3. 采用清分或双合同模式规避优加与广联直接关联交易,确保财务路径合规。
4. 拍卖平台增设"包店车源"与"试拍车源"双频道,区分保收与竞价交易规则。
5. 推出轻量化拓店政策:通过企微引流、线索奖励及资金赋能激励一线销售。
6. 要求1月起全面切换新业务模式,加快平台全链路跑通与专项人员招聘。
**【详细任务列表】**
| 编号 | 类别 | 事项 | 责任人 | 计划完成时间 |
| --- | --- | --- | --- | --- |
| 1 | 财务合规 | 拟定优加与广联框架合同,明确资产管理费与资金占用费结算标准,确保体外合规运作。 | 说话人 4 | 近期 |
| 2 | 平台运营 | 开发并上线"包店车源"与"试拍车源"双频道,配置差异化保留价规则,支撑分类处置。 | 说话人 2 | 近期 |
| 3 | 商务政策 | 制定一线销售轻量化拓店激励方案,明确企微添加与线索转化奖励标准,于1月下发执行。 | 说话人 1 | 本周内 |
| 4 | 营销推广 | 精修内外部招商海报并补充引流二维码,经人工审核后统一分发,用于门店与朋友圈投放。 | 说话人 4 | 会后立即 |
| 5 | 流程跑通 | 验证收车、上拍、改价至过户结算全链路,修复系统改价卡点与财务对账逻辑,保障流程顺畅。 | 说话人 3 | 1月前 |
| 6 | 团队建设 | 落实车商拓展运营人员(肖峰等)到岗,明确驻店评估与赋能拓店职责,建立周复盘机制。 | 说话人 1 | 下周内 |
| 7 | 制度流程 | 完成OA系统二手车审批流配置,将资金拨付与业务单据全量接入优加体系,实现线上闭环。 | 说话人 2 | 近期 |
\ No newline at end of file \ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
封装流程: 封装流程:
1. `evaluate()` 锁外检查 `_running_tasks`(有在途任务则走 busy 分支,不排队) 1. `evaluate()` 锁外检查 `_running_tasks`(有在途任务则走 busy 分支,不排队)
2. 获取 session 锁(`_get_lock` 按 session 串行化),等待非 text 消息的补充窗口(默认 6s) 2. 获取 session 锁(`_get_lock` 按 session 串行化),等待非 text 消息的补充窗口(默认 6s)
3. `_classify_and_rewrite()` 调 LLM 做二元激活识别(chat vs pass),无历史上下文,只看当前消息 3. `_classify_and_rewrite()` — 当前为直通桩(直接放行所有消息,跳过 LLM 分类)。MessageGate 激活识别功能暂时搁置,待后续重新启用。
4. 根据 intent 分支: 4. 根据 intent 分支:
- `chat` → `_handle_chat()` 只追加用户消息到 conversation_history,不触发 AgentHub,不发 IM("已读不回") - `chat` → `_handle_chat()` 只追加用户消息到 conversation_history,不触发 AgentHub,不发 IM("已读不回")
- `pass` → `_handle_actionable()` 提取 query/file_url,调用 `AgentHub.process_message()` - `pass` → `_handle_actionable()` 提取 query/file_url,调用 `AgentHub.process_message()`
...@@ -43,15 +43,15 @@ ...@@ -43,15 +43,15 @@
2. `get_or_create_session()` 获取/创建会话 2. `get_or_create_session()` 获取/创建会话
3. 消费 `intent_session` 积压消息(busy 分支写入的),拼入 `user_query` 前置,清空 KV 字段 3. 消费 `intent_session` 积压消息(busy 分支写入的),拼入 `user_query` 前置,清空 KV 字段
4. `SessionMemory.get_messages()` 加载历史消息 4. `SessionMemory.get_messages()` 加载历史消息
5. `_build_main_prompt()` 组装 system prompt(DB prompt + soul_guide 回复风格 + 子Agent职责列表 + DISPATCH_GUIDE + THINKING_GUIDE) 5. `_build_main_prompt()` 组装 system prompt(DB prompt + 子Agent职责列表 + soul_guide 回复风格框架)
6. 创建 `ReActAgent`(AgentScope),注入 `InMemoryMemory` + `Toolkit`,主 Agent 用 `self.model`,子 Agent 用 `self.sub_model` (temp=0.2) 6. 创建 `ReActAgent`(AgentScope),注入 `InMemoryMemory` + 专属 `Toolkit`(`agent_toolkits[code]`),主 Agent 用 `self.model`,子 Agent 用 `self.sub_model` (temp=0.2)
7. `agent.reply(user_msg)` 执行 ReAct 循环(推理→工具调用→观察→再推理) 7. `agent.reply(user_msg)` 执行 ReAct 循环(推理→工具调用→观察→再推理)
8. `_call_sub_agent()` 子 Agent 创建与执行(通过 `call_sub_agent` 工具触发,使用 `self.sub_model`) 8. `_call_sub_agent()` 子 Agent 创建与执行(通过 `call_sub_agent` 工具触发,使用 `self.sub_model`)
- 自调用防护:拒绝调用 steward 自己的 code,引导调用发言人 Agent - 自调用防护:拒绝调用 steward 自己的 code,引导调用发言人 Agent
- 子Agent ReAct 消息通过 `_save_tool_interactions()` 写入 SessionMemory,落 DB - 子Agent ReAct 消息通过 `_save_tool_interactions()` 写入 SessionMemory,落 DB
- 口 Agent(code: -1)排除 `call_sub_agent` 工具,纯总结回复 - 口 Agent(code: -1)排除 `call_sub_agent` 工具,纯总结回复
9. 回复处理: 9. 回复处理:
- `call_count >= 1`:主Agent 静默——不写 KV、不存 DB、不发送(发言人已发送最终回复) - `call_count >= 1`:主Agent 静默——不写 KV(`memory.remove_last()`)、不存 DB、不发送 IM(发言人已发送最终回复)
- `call_count == 0`:主Agent 直接回复——正常写入 + 存 DB + PostReplyHook 发 IM - `call_count == 0`:主Agent 直接回复——正常写入 + 存 DB + PostReplyHook 发 IM
10. `save_to_db()` 持久化会话 10. `save_to_db()` 持久化会话
...@@ -112,10 +112,10 @@ ...@@ -112,10 +112,10 @@
| `app/hooks/` | 是 | `PostReplyHook`(回复后 IM 发送)、`Hook` 基类 | | `app/hooks/` | 是 | `PostReplyHook`(回复后 IM 发送)、`Hook` 基类 |
| `app/infrastructure/session_store.py` | 是 | `SessionStore` 内存 KV,`ActiveSessionService` 和 `SessionBuffer` 的底层存储 | | `app/infrastructure/session_store.py` | 是 | `SessionStore` 内存 KV,`ActiveSessionService` 和 `SessionBuffer` 的底层存储 |
| `app/infrastructure/file_parser.py` | 是 | `FileParser` + `OSSClient`,`FileService` 的底层依赖 | | `app/infrastructure/file_parser.py` | 是 | `FileParser` + `OSSClient`,`FileService` 的底层依赖 |
| `app/config/loader.py` | 是 | `ConfigLoader` 加载 models/mappings/settings JSON 配置,Agent 从 DB `ai_agents` 表加载 | | `app/config/loader.py` | 是 | `ConfigLoader` 加载 models/settings JSON 配置,Agent 从 DB `ai_agents` 表加载 |
| `app/model/session.py` | 是 | `Session`、`ConversationHistory` ORM 模型 | | `app/model/session.py` | 是 | `Session`、`ConversationHistory` ORM 模型 |
| `ai_agents` 表 | 是 | Agent 配置(name, code, description, is_steward),通过 `ai_agent_skills` 关联 skills | | `ai_agents` 表 | 是 | Agent 配置(name, code, description, is_steward),通过 `ai_agent_skills` 关联 skills |
| `config/models.json` | 是 | 模型配置(main/sub/thinking_summary/message_gate/meeting_minutes) | | `config/models.json` | 是 | 模型配置(main/thinking_summary/message_gate/meeting_minutes) |
| `skills/` | 是 | Skill 目录,每个子目录有 `SKILL.md`,由 `Toolkit.register_agent_skill()` 加载 | | `skills/` | 是 | Skill 目录,每个子目录有 `SKILL.md`,由 `Toolkit.register_agent_skill()` 加载 |
| `soul/` | 是 | 回复风格(agent.md)和 thinking 摘要提示词(thinking-summarize.md),启动时加载注入 prompt | | `soul/` | 是 | 回复风格(agent.md)和 thinking 摘要提示词(thinking-summarize.md),启动时加载注入 prompt |
...@@ -149,7 +149,7 @@ MessageGate.evaluate() ← app/service/message_gate.py ...@@ -149,7 +149,7 @@ MessageGate.evaluate() ← app/service/message_gate.py
│ │
├── 获取 session 锁(按 session_id 串行化) ├── 获取 session 锁(按 session_id 串行化)
├── 等待非 text 消息补充窗口(默认 6s) ├── 等待非 text 消息补充窗口(默认 6s)
├── _classify_and_rewrite() → LLM 二元激活识别(chat/pass) ├── _classify_and_rewrite() → 当前为直通桩(直接返回 pass),跳过 LLM 分类
│ │
├── intent=chat → _handle_chat() ├── intent=chat → _handle_chat()
│ 追加用户消息到 conversation_history → save_to_db() │ 追加用户消息到 conversation_history → save_to_db()
...@@ -171,7 +171,7 @@ MessageGate.evaluate() ← app/service/message_gate.py ...@@ -171,7 +171,7 @@ MessageGate.evaluate() ← app/service/message_gate.py
│ 加载 conversation_history,超限自动压缩 │ 加载 conversation_history,超限自动压缩
│ │
├── _build_main_prompt() ├── _build_main_prompt()
│ DB prompt + soul/agent.md 回复风格 + 子Agent职责列表 + DISPATCH_GUIDE + THINKING_GUIDE │ DB prompt + 子Agent职责列表 + soul/agent.md 回复风格框架
│ │
├── 创建 ReActAgent (AgentScope) ├── 创建 ReActAgent (AgentScope)
│ 主 Agent 用 self.model,子 Agent 用 self.sub_model (temp=0.2) │ 主 Agent 用 self.model,子 Agent 用 self.sub_model (temp=0.2)
...@@ -212,6 +212,10 @@ MessageGate.evaluate() ← app/service/message_gate.py ...@@ -212,6 +212,10 @@ MessageGate.evaluate() ← app/service/message_gate.py
当 MessageGate 评估异常时,endpoint 的 `_process_message_async_via_gate` 会 catch 异常并兜底直接调用 `AgentHub.process_message()`,确保消息不会丢失。 当 MessageGate 评估异常时,endpoint 的 `_process_message_async_via_gate` 会 catch 异常并兜底直接调用 `AgentHub.process_message()`,确保消息不会丢失。
| 模型架构
> **暂时搁置:** `_classify_and_rewrite()` 当前为直通桩,不做 LLM 分类。`_handle_casual()` 和 `_handle_incomplete()` 方法保留在代码中但未被调用,待后续重新启用消息过滤功能。
### 模型架构 ### 模型架构
| 实例 | 模型 | temperature | 用途 | | 实例 | 模型 | temperature | 用途 |
...@@ -219,20 +223,13 @@ MessageGate.evaluate() ← app/service/message_gate.py ...@@ -219,20 +223,13 @@ MessageGate.evaluate() ← app/service/message_gate.py
| `self.model` | qwen3.6-plus | 默认 | 主 Agent ReAct 推理 | | `self.model` | qwen3.6-plus | 默认 | 主 Agent ReAct 推理 |
| `self.sub_model` | qwen3.6-plus | 0.2 | 子 Agent ReAct 推理 | | `self.sub_model` | qwen3.6-plus | 0.2 | 子 Agent ReAct 推理 |
| `self.thinking_summary_model` | deepseek-v4-flash | 默认 | thinking 摘要化(快、便宜) | | `self.thinking_summary_model` | deepseek-v4-flash | 默认 | thinking 摘要化(快、便宜) |
| MessageGate 模型 | deepseek-v4-flash | 默认 | 意图分类 + query 重写(轻量任务) | | MessageGate 模型 | deepseek-v4-flash | 默认 | 暂时搁置(当前直通不放行分类,_classify_and_rewrite 为桩) |
### Prompt 装配顺序 ### Prompt 装配顺序
``` ```
_build_main_prompt: agent.prompt → soul_guide 回复风格 → 子Agent职责列表 → DISPATCH_GUIDE → THINKING_GUIDE _build_main_prompt: agent.prompt (DB角色定义+调度规则) → 子Agent职责列表 → soul_guide (回复风格框架)
_build_sub_agent_prompt: agent.prompt → soul_guide → THINKING_GUIDE _build_sub_agent_prompt: agent.prompt → soul_guide
``` ```
### DISPATCH_GUIDE(调度规则) 调度规则(原 DISPATCH_GUIDE)已集成到 DB `ai_agents.prompt` 中,不再作为独立常量拼接。
```
1. 分析用户意图,判断是否在你的能力范围内(追问、澄清、简单对话等),可以直接回复
2. 复杂任务拆解为子任务步骤,按顺序调用子Agent(通过 call_sub_agent 工具),每次一个
3. 所有子Agent 执行完毕后,必须调用"发言人"Agent(调用码: -1)总结回复
4. 不要再调用同一个子Agent重复处理同一任务
```
...@@ -13,6 +13,12 @@ from app.hooks.post_reply import PostReplyHook ...@@ -13,6 +13,12 @@ from app.hooks.post_reply import PostReplyHook
from app.service.memory import SessionMemory from app.service.memory import SessionMemory
from agentscope.model import OpenAIChatModel from agentscope.model import OpenAIChatModel
from agentscope.formatter import OpenAIChatFormatter as _OpenAIChatFormatter from agentscope.formatter import OpenAIChatFormatter as _OpenAIChatFormatter
from agentscope.message import Msg
from agentscope.message._message_block import TextBlock
from agentscope.tool._response import ToolResponse
from agentscope.tool import execute_python_code, execute_shell_command
from agentscope.agent import ReActAgent
from agentscope.memory import InMemoryMemory
class OpenAIChatFormatter(_OpenAIChatFormatter): class OpenAIChatFormatter(_OpenAIChatFormatter):
...@@ -38,12 +44,6 @@ class OpenAIChatFormatter(_OpenAIChatFormatter): ...@@ -38,12 +44,6 @@ class OpenAIChatFormatter(_OpenAIChatFormatter):
] ]
return await super()._format(msgs) return await super()._format(msgs)
from agentscope.message import Msg
from agentscope.message._message_block import TextBlock
from agentscope.tool._response import ToolResponse
from agentscope.tool import execute_python_code, execute_shell_command
from agentscope.agent import ReActAgent
from agentscope.memory import InMemoryMemory
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -746,7 +746,7 @@ class AgentHub: ...@@ -746,7 +746,7 @@ class AgentHub:
Args: Args:
file_path: File path relative to the project root, file_path: File path relative to the project root,
e.g. 'skills/meeting_minutes/SKILL.md' or 'config/agents.json' e.g. 'skills/meeting_minutes/SKILL.md' or 'soul/agent.md'
Returns: Returns:
File content as text, truncated to 10000 characters if too large. File content as text, truncated to 10000 characters if too large.
......
...@@ -212,18 +212,6 @@ class MessageGate: ...@@ -212,18 +212,6 @@ class MessageGate:
self.session_service.save_to_db(session_id) self.session_service.save_to_db(session_id)
@staticmethod @staticmethod
def _extract_text(response: Any) -> str:
"""从 OpenAI 兼容响应中提取文本。"""
if hasattr(response, "content"):
content = response.content
if isinstance(content, list):
for block in content:
if isinstance(block, dict) and block.get("type") == "text":
return block.get("text", "")
return str(content)
return str(response)
@staticmethod
def _merge_text_from_pending(pending: List[Dict[str, Any]]) -> str: def _merge_text_from_pending(pending: List[Dict[str, Any]]) -> str:
"""从 pending 列表中提取文本,与 _classify_and_rewrite 拼 merged_text 逻辑一致。""" """从 pending 列表中提取文本,与 _classify_and_rewrite 拼 merged_text 逻辑一致。"""
parts = [] parts = []
......
{
"agent_accounts": {
"main": "bot_main_001",
"meeting": "bot_meeting_001"
},
"account_agents": {
"bot_main_001": "main",
"bot_meeting_001": "meeting"
}
}
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
"model_name": "qwen3.7-plus", "model_name": "qwen3.7-plus",
"api_key": "sk-107dd26bca184e39bd1744af7d634488" "api_key": "sk-107dd26bca184e39bd1744af7d634488"
}, },
"summary": {
"type": "openai_compatible",
"api_base": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"model_name": "qwen3.7-plus",
"api_key": "sk-107dd26bca184e39bd1744af7d634488"
},
"message_gate": { "message_gate": {
"type": "openai_compatible", "type": "openai_compatible",
"api_base": "https://dashscope.aliyuncs.com/compatible-mode/v1", "api_base": "https://dashscope.aliyuncs.com/compatible-mode/v1",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!