fix: use previousSessionEntry for pre-reset learning and preserve session file path
This commit is contained in:
parent
d000dcad94
commit
672728a692
@ -80,14 +80,7 @@ export const handleCompactCommand: CommandHandler = async (params) => {
|
||||
groupChannel: params.sessionEntry.groupChannel,
|
||||
groupSpace: params.sessionEntry.space,
|
||||
spawnedBy: params.sessionEntry.spawnedBy,
|
||||
sessionFile: resolveSessionFilePath(
|
||||
sessionId,
|
||||
params.sessionEntry,
|
||||
resolveSessionFilePathOptions({
|
||||
agentId: params.agentId,
|
||||
storePath: params.storePath,
|
||||
}),
|
||||
),
|
||||
sessionFile: params.sessionEntry.sessionFile,
|
||||
workspaceDir: params.workspaceDir,
|
||||
agentDir: params.agentDir,
|
||||
config: params.cfg,
|
||||
|
||||
@ -223,10 +223,16 @@ export async function handleCommands(params: HandleCommandsParams): Promise<Comm
|
||||
: undefined;
|
||||
|
||||
// Determine which session to learn from (after ACP resolution)
|
||||
// For non-ACP resets, use previousSessionEntry because initSessionState already rotated to fresh session
|
||||
const targetSessionKey = boundAcpKey ?? params.sessionKey;
|
||||
const targetSessionEntry = boundAcpKey
|
||||
? resolveSessionEntryForHookSessionKey(params.sessionStore, boundAcpKey)
|
||||
: params.sessionEntry;
|
||||
let targetSessionEntry: typeof params.sessionEntry;
|
||||
if (boundAcpKey) {
|
||||
targetSessionEntry = resolveSessionEntryForHookSessionKey(params.sessionStore, boundAcpKey);
|
||||
} else if (params.previousSessionEntry?.sessionId) {
|
||||
targetSessionEntry = params.previousSessionEntry;
|
||||
} else {
|
||||
targetSessionEntry = params.sessionEntry;
|
||||
}
|
||||
|
||||
// Trigger learning before reset/new commands (after ACP target resolution)
|
||||
if (targetSessionEntry?.sessionId) {
|
||||
@ -238,14 +244,7 @@ export async function handleCommands(params: HandleCommandsParams): Promise<Comm
|
||||
groupChannel: targetSessionEntry.groupChannel,
|
||||
groupSpace: targetSessionEntry.space,
|
||||
spawnedBy: targetSessionEntry.spawnedBy,
|
||||
sessionFile: resolveSessionFilePath(
|
||||
targetSessionEntry.sessionId,
|
||||
targetSessionEntry,
|
||||
resolveSessionFilePathOptions({
|
||||
agentId: params.agentId,
|
||||
storePath: params.storePath,
|
||||
}),
|
||||
),
|
||||
sessionFile: targetSessionEntry.sessionFile,
|
||||
workspaceDir: params.workspaceDir,
|
||||
agentDir: params.agentDir,
|
||||
config: params.cfg,
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { runEmbeddedPiAgent } from "../../agents/pi-embedded.js";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { resolveSessionFilePath, resolveSessionFilePathOptions } from "../../config/sessions.js";
|
||||
import { logVerbose } from "../../globals.js";
|
||||
|
||||
const LEARN_SYSTEM_PROMPT = [
|
||||
@ -54,17 +53,11 @@ export async function runLearnForSession(params: {
|
||||
? `Focus area: ${params.customFocus}. ${LEARN_DEFAULT_PROMPT}`
|
||||
: LEARN_DEFAULT_PROMPT;
|
||||
|
||||
const sessionFilePath = resolveSessionFilePath(
|
||||
params.sessionId,
|
||||
{ sessionId: params.sessionId, sessionFile: params.sessionFile },
|
||||
resolveSessionFilePathOptions({ agentId: undefined, storePath: undefined }),
|
||||
);
|
||||
|
||||
try {
|
||||
await runEmbeddedPiAgent({
|
||||
sessionId: params.sessionId,
|
||||
sessionKey: params.sessionKey,
|
||||
sessionFile: sessionFilePath,
|
||||
sessionFile: params.sessionFile,
|
||||
messageChannel: params.messageChannel,
|
||||
groupId: params.groupId,
|
||||
groupChannel: params.groupChannel,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user