feat(agent): 任务内主 Agent 支持多会话,可切换且上下文可重置
主 Agent 会话原为一个任务恒定单例,对话历史随 transcript 只增不减、 上下文越滚越大。现引入会话分段(seq):新建会话切一个干净的 transcript 段,任务的图谱/资产/目标共享保留,旧段以只读历史随时切回查看。 - db: 新增 main_sessions 表与 activity.main_seg 列(ALTER ADD COLUMN IF NOT EXISTS 兼容旧库);ActivitySessionFilter 按段过滤(段 0 兼容 旧 NULL 行);新增 CurrentMainSeg/ListMainSessions/NewMainSession; per-session token 统计按 main:<seg> 分段 - agent: MainAgent.Chat 增加 mainSeg,transcript SessionID 分段 (段 0 保留旧名 exp<id>-main 兼容既有对话) - server: parseActivitySession 支持 main:<seq>;chat handler 每轮 stamp 当前段;新增 GET main-sessions / POST main-session/new - web: 主 Agent 分组渲染多段会话,支持新建(轻确认)、切换、旧段只读
This commit is contained in:
1 parent
9ad88d5ce8
commit
ee3eb22433
8 files changed
+360
-51
No files matched your search
@@ -678,6 +678,16 @@ export const api = {
|
||||
}));
|
||||
},
|
||||
|
||||
// Main-agent conversation segments of a task. Each segment is a resettable session
|
||||
// (clean transcript/context) over the same task; `current` is the writable one.
|
||||
mainSessions: (task: string) =>
|
||||
get<{ sessions: { seq: number; created_at: string }[]; current: number }>(
|
||||
`/exploration/main-sessions${tq(task)}`,
|
||||
).then((r) => ({ sessions: arr(r.sessions), current: r.current ?? 0 })),
|
||||
// Start a fresh main-agent session segment (does not touch the task's graph/assets/goal).
|
||||
newMainSession: (task: string) =>
|
||||
post<{ seq: number; created_at: string; current: number }>(`/exploration/main-session/new${tq(task)}`),
|
||||
|
||||
// ---- traffic / audit / report / chat ----
|
||||
audit: (task?: string) => get<Audit>(`/audit${tq(task)}`),
|
||||
traffic: (page = 0, size = 100, host = "", method = "", q = "") =>
|
||||
|
||||
@@ -627,6 +627,7 @@ export interface Activity {
|
||||
};
|
||||
source_task_id?: string;
|
||||
inherited?: boolean;
|
||||
main_seg?: number; // main-agent conversation segment (present only on worker="mainagent" rows)
|
||||
// token usage (present only on kind='result')
|
||||
input_tokens?: number;
|
||||
output_tokens?: number;
|
||||
@@ -829,6 +830,8 @@ export interface Session {
|
||||
intent_id?: string;
|
||||
source_task_id?: string;
|
||||
inherited?: boolean;
|
||||
seg?: number; // main-agent session: which conversation segment (0 = original)
|
||||
isCurrentMain?: boolean; // main-agent session: the writable current segment
|
||||
}
|
||||
|
||||
// ---- Security ----
|
||||
|
||||
Reference in new issue
Block a user