feat(beaver): 完成Task Team功能v1实现,重构后端架构支持统一内核
新增内部Task系统,包括验证、反馈门控机制,实现自动质量验证 (通过率>=0.75)和用户反馈闭环(satisfied/revise/abandon)。 实现Agent Team v1协调器,支持sequence/parallel/dag执行策略, sub-agent复用主AgentLoop,每个run使用独立memory snapshot。 建立Skill学习pipeline,包含draft/审核/发布/回滚完整生命周期, 通过Task验证通过且用户满意才生成学习候选。 重构目录结构,移除third_party依赖,建立统一engine内核, 所有agent共享运行时基础组件。 更新ContextBuilder清理provider消息字段,增强SkillContext版本管理, 集成TaskExecutionPlanner和TaskSkillResolver实现技能解析机制。
This commit is contained in:
@ -91,6 +91,19 @@ class SessionManager:
|
||||
|
||||
return self.store.get_run_event_records(session_id, run_id)
|
||||
|
||||
def update_latest_assistant_event_payload(
|
||||
self,
|
||||
session_id: str,
|
||||
run_id: str,
|
||||
updates: dict[str, Any],
|
||||
) -> None:
|
||||
"""把 run 级 UI 状态投影回最新 assistant 可见消息。"""
|
||||
|
||||
self.store.update_latest_assistant_event_payload(session_id, run_id, updates)
|
||||
|
||||
def set_run_context_visible(self, session_id: str, run_id: str, visible: bool) -> None:
|
||||
self.store.set_run_context_visible(session_id, run_id, visible)
|
||||
|
||||
def list_run_ids(self, session_id: str) -> list[str]:
|
||||
"""按出现顺序列出当前 session 的所有 run_id。"""
|
||||
|
||||
|
||||
@ -75,6 +75,19 @@ class MessageRecord:
|
||||
"role": self.role,
|
||||
"content": self.content,
|
||||
}
|
||||
if self.run_id:
|
||||
payload["run_id"] = self.run_id
|
||||
if self.event_payload:
|
||||
if self.event_payload.get("task_id"):
|
||||
payload["task_id"] = self.event_payload.get("task_id")
|
||||
if self.event_payload.get("task_status"):
|
||||
payload["task_status"] = self.event_payload.get("task_status")
|
||||
if self.event_payload.get("validation_status"):
|
||||
payload["validation_status"] = self.event_payload.get("validation_status")
|
||||
if self.event_payload.get("feedback_state"):
|
||||
payload["feedback_state"] = self.event_payload.get("feedback_state")
|
||||
if self.event_payload.get("feedback_error"):
|
||||
payload["feedback_error"] = self.event_payload.get("feedback_error")
|
||||
if self.tool_name:
|
||||
payload["tool_name"] = self.tool_name
|
||||
if self.tool_calls:
|
||||
|
||||
@ -432,6 +432,71 @@ class SessionStore:
|
||||
)
|
||||
return [MessageRecord.from_row(row) for row in rows]
|
||||
|
||||
def update_latest_assistant_event_payload(
|
||||
self,
|
||||
session_id: str,
|
||||
run_id: str,
|
||||
updates: dict[str, Any],
|
||||
) -> None:
|
||||
"""Merge payload fields into the latest visible assistant message for a run."""
|
||||
|
||||
if not updates:
|
||||
return
|
||||
|
||||
def _do(conn: sqlite3.Connection) -> None:
|
||||
row = conn.execute(
|
||||
"""
|
||||
SELECT id, event_payload
|
||||
FROM messages
|
||||
WHERE session_id = ?
|
||||
AND run_id = ?
|
||||
AND role = 'assistant'
|
||||
AND event_type = 'assistant_message_added'
|
||||
AND context_visible = 1
|
||||
ORDER BY timestamp DESC, id DESC
|
||||
LIMIT 1
|
||||
""",
|
||||
(session_id, run_id),
|
||||
).fetchone()
|
||||
if row is None:
|
||||
return
|
||||
payload: dict[str, Any] = {}
|
||||
if row["event_payload"]:
|
||||
try:
|
||||
parsed = json.loads(row["event_payload"])
|
||||
if isinstance(parsed, dict):
|
||||
payload = parsed
|
||||
except json.JSONDecodeError:
|
||||
payload = {}
|
||||
payload.update(updates)
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE messages
|
||||
SET event_payload = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(json.dumps(payload, ensure_ascii=False, sort_keys=True), row["id"]),
|
||||
)
|
||||
|
||||
self._execute_write(_do)
|
||||
|
||||
def set_run_context_visible(self, session_id: str, run_id: str, visible: bool) -> None:
|
||||
"""Set context visibility for all currently visible events in one run."""
|
||||
|
||||
def _do(conn: sqlite3.Connection) -> None:
|
||||
conn.execute(
|
||||
"""
|
||||
UPDATE messages
|
||||
SET context_visible = ?
|
||||
WHERE session_id = ?
|
||||
AND run_id = ?
|
||||
AND context_visible != ?
|
||||
""",
|
||||
(1 if visible else 0, session_id, run_id, 1 if visible else 0),
|
||||
)
|
||||
|
||||
self._execute_write(_do)
|
||||
|
||||
def get_messages_as_conversation(self, session_id: str) -> list[dict[str, Any]]:
|
||||
messages: list[dict[str, Any]] = []
|
||||
for record in self.get_event_records(session_id):
|
||||
|
||||
Reference in New Issue
Block a user