fix: land multi-agent session path fix + regressions (#15103) (#15448)

Co-authored-by: Josh Lehman <josh@martian.engineering>
This commit is contained in:
Peter Steinberger
2026-02-13 14:17:24 +01:00
committed by GitHub
parent 5d37b204c0
commit 990413534a
11 changed files with 274 additions and 37 deletions

View File

@@ -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 });

View File

@@ -224,6 +224,7 @@ export async function buildStatusReply(params: {
verboseDefault: agentDefaults.verboseDefault,
elevatedDefault: agentDefaults.elevatedDefault,
},
agentId: statusAgentId,
sessionEntry,
sessionKey,
sessionScope,

View File

@@ -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;