mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:10:52 +00:00
fix: revert skipAfterTurn, let finalize ingest the final message
- Remove loopHookActive flag, skipAfterTurn param, and the conditional skip in finalizeAttemptContextEngineTurn - The finalize afterTurn must run to ingest the final assistant message which is appended after the last transformContext call - lossless-claw deduplicates internally so the overlap with the loop hook's earlier ingestion is benign
This commit is contained in:
@@ -199,9 +199,6 @@ export async function finalizeAttemptContextEngineTurn(params: {
|
||||
}) => Promise<unknown>;
|
||||
sessionManager: unknown;
|
||||
warn: (message: string) => void;
|
||||
/** When true, skip the afterTurn/ingest calls because the loop hook already
|
||||
* handled per-iteration ingestion during the tool loop. Maintenance still runs. */
|
||||
skipAfterTurn?: boolean;
|
||||
}) {
|
||||
if (!params.contextEngine) {
|
||||
return { postTurnFinalizationSucceeded: true };
|
||||
@@ -209,8 +206,7 @@ export async function finalizeAttemptContextEngineTurn(params: {
|
||||
|
||||
let postTurnFinalizationSucceeded = true;
|
||||
|
||||
if (!params.skipAfterTurn) {
|
||||
if (typeof params.contextEngine.afterTurn === "function") {
|
||||
if (typeof params.contextEngine.afterTurn === "function") {
|
||||
try {
|
||||
await params.contextEngine.afterTurn({
|
||||
sessionId: params.sessionIdUsed,
|
||||
@@ -255,7 +251,7 @@ export async function finalizeAttemptContextEngineTurn(params: {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (
|
||||
!params.promptError &&
|
||||
|
||||
@@ -997,7 +997,6 @@ export async function runEmbeddedAttempt(
|
||||
queueYieldInterruptForSession = () => {
|
||||
queueSessionsYieldInterruptMessage(activeSession);
|
||||
};
|
||||
let loopHookActive = false;
|
||||
if (params.contextEngine?.info?.ownsCompaction !== true) {
|
||||
removeToolResultContextGuard = installToolResultContextGuard({
|
||||
agent: activeSession.agent,
|
||||
@@ -1018,7 +1017,6 @@ export async function runEmbeddedAttempt(
|
||||
tokenBudget: params.contextTokenBudget,
|
||||
modelId: params.modelId,
|
||||
});
|
||||
loopHookActive = true;
|
||||
}
|
||||
const cacheTrace = createCacheTrace({
|
||||
cfg: params.config,
|
||||
@@ -2218,7 +2216,6 @@ export async function runEmbeddedAttempt(
|
||||
prePromptMessageCount,
|
||||
tokenBudget: params.contextTokenBudget,
|
||||
runtimeContext: afterTurnRuntimeContext,
|
||||
skipAfterTurn: loopHookActive,
|
||||
runMaintenance: async (contextParams) =>
|
||||
await runContextEngineMaintenance({
|
||||
contextEngine: contextParams.contextEngine as never,
|
||||
|
||||
Reference in New Issue
Block a user