Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion examples/openclaw-plugin/services/context-lifecycle-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,11 @@ function assemblePassthrough(
return { messages: liveMessages, estimatedTokens: originalTokens };
}

function isSessionNotFoundError(err: unknown): boolean {
const errorMessage = String(err);
return errorMessage.includes("[NOT_FOUND]") && errorMessage.includes("Session not found");
}

export async function assembleOpenVikingSession({
sessionId,
sessionKey,
Expand Down Expand Up @@ -627,6 +632,27 @@ export async function assembleOpenVikingSession({
...(instruction.text ? { systemPromptAddition: instruction.text } : {}),
};
} catch (err) {
if (isSessionNotFoundError(err)) {
const errorMessage = String(err);
logger.info(
`openviking: assemble skipped because OV session does not exist ` +
`(session=${ovSessionId}, tokenBudget=${tokenBudget}, agentId=${resolveAgentId(ovSessionId)})`,
);
return assemblePassthrough({
diag,
ovSessionId,
reason: "session_not_found",
liveMessages: messages,
originalTokens,
extra: {
error: errorMessage,
tokenBudget,
agentId: resolveAgentId(ovSessionId),
senderIdFound: sender.found,
senderId: sender.senderId ?? null,
},
});
}
logger.warn?.(
`openviking: assemble failed for session=${ovSessionId}, ` +
`tokenBudget=${tokenBudget}, agentId=${resolveAgentId(ovSessionId)}: ${String(err)}`,
Expand Down Expand Up @@ -1192,7 +1218,7 @@ export async function compactOpenVikingSession({
};
} catch (err) {
const errorMessage = String(err);
if (errorMessage.includes("[NOT_FOUND]") && errorMessage.includes("Session not found")) {
if (isSessionNotFoundError(err)) {
logger.info(
`openviking: compact skipped because OV session does not exist ` +
`(session=${ovSessionId}, agentId=${agentId})`,
Expand Down
Loading