mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:41:37 +00:00
Co-authored-by: Josh Lehman <josh@martian.engineering>
This commit is contained in:
committed by
GitHub
parent
5d37b204c0
commit
990413534a
@@ -167,6 +167,7 @@ export const handleUsageCommand: CommandHandler = async (params, allowTextComman
|
||||
sessionEntry: params.sessionEntry,
|
||||
sessionFile: params.sessionEntry?.sessionFile,
|
||||
config: params.cfg,
|
||||
agentId: params.agentId,
|
||||
});
|
||||
const summary = await loadCostUsageSummary({ days: 30, config: params.cfg });
|
||||
|
||||
|
||||
@@ -224,6 +224,7 @@ export async function buildStatusReply(params: {
|
||||
verboseDefault: agentDefaults.verboseDefault,
|
||||
elevatedDefault: agentDefaults.elevatedDefault,
|
||||
},
|
||||
agentId: statusAgentId,
|
||||
sessionEntry,
|
||||
sessionKey,
|
||||
sessionScope,
|
||||
|
||||
@@ -55,12 +55,13 @@ export type SessionInitResult = {
|
||||
|
||||
function forkSessionFromParent(params: {
|
||||
parentEntry: SessionEntry;
|
||||
agentId: string;
|
||||
sessionsDir: string;
|
||||
}): { sessionId: string; sessionFile: string } | null {
|
||||
const parentSessionFile = resolveSessionFilePath(
|
||||
params.parentEntry.sessionId,
|
||||
params.parentEntry,
|
||||
{ sessionsDir: params.sessionsDir },
|
||||
{ agentId: params.agentId, sessionsDir: params.sessionsDir },
|
||||
);
|
||||
if (!parentSessionFile || !fs.existsSync(parentSessionFile)) {
|
||||
return null;
|
||||
@@ -225,11 +226,7 @@ export async function initSessionState(params: {
|
||||
? evaluateSessionFreshness({ updatedAt: entry.updatedAt, now, policy: resetPolicy }).fresh
|
||||
: false;
|
||||
|
||||
// When this is the first user message in a thread, the session entry may already
|
||||
// exist (created by recordInboundSession in prepare.ts), but we should still treat
|
||||
// it as a new session so that thread context (history/starter/fork) is applied.
|
||||
const forceNewForThread = Boolean(ctx.IsFirstThreadTurn) && !resetTriggered;
|
||||
if (!isNewSession && freshEntry && !forceNewForThread) {
|
||||
if (!isNewSession && freshEntry) {
|
||||
sessionId = entry.sessionId;
|
||||
systemSent = entry.systemSent ?? false;
|
||||
abortedLastRun = entry.abortedLastRun ?? false;
|
||||
@@ -335,6 +332,7 @@ export async function initSessionState(params: {
|
||||
);
|
||||
const forked = forkSessionFromParent({
|
||||
parentEntry: sessionStore[parentSessionKey],
|
||||
agentId,
|
||||
sessionsDir: path.dirname(storePath),
|
||||
});
|
||||
if (forked) {
|
||||
@@ -358,7 +356,6 @@ export async function initSessionState(params: {
|
||||
// Clear stale token metrics from previous session so /status doesn't
|
||||
// display the old session's context usage after /new or /reset.
|
||||
sessionEntry.totalTokens = undefined;
|
||||
sessionEntry.totalTokensFresh = false;
|
||||
sessionEntry.inputTokens = undefined;
|
||||
sessionEntry.outputTokens = undefined;
|
||||
sessionEntry.contextTokens = undefined;
|
||||
|
||||
Reference in New Issue
Block a user