fix(advisor): expose provider sessionId in stats + show failure status in formatAdvisorStatus
This commit is contained in:
@@ -16929,7 +16929,7 @@ export class AgentSession {
|
||||
tokens: { input, output, reasoning, cacheRead, cacheWrite, total: totalTokens },
|
||||
cost,
|
||||
messages: { user, assistant, total: messages.length },
|
||||
sessionId: advisor.slug ? `${this.sessionId}-advisor-${advisor.slug}` : `${this.sessionId}-advisor`,
|
||||
sessionId: advisor.agent.sessionId,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16958,7 +16958,7 @@ export class AgentSession {
|
||||
if (s.tokens.cacheRead > 0) spendParts.push(`${s.tokens.cacheRead.toLocaleString()} cache read`);
|
||||
if (s.tokens.cacheWrite > 0) spendParts.push(`${s.tokens.cacheWrite.toLocaleString()} cache write`);
|
||||
const spendLine = `Spend: ${spendParts.join(", ")}, $${s.cost.toFixed(4)}`;
|
||||
if (!s.model) return `Advisor "${s.name}" is ${s.status.replace("_", " ")}.`;
|
||||
if (!s.model || s.status !== "running") return `Advisor "${s.name}" is ${s.status.replace("_", " ")}.`;
|
||||
return `Advisor is enabled (${s.model.provider}/${s.model.id}). ${contextLine}. ${spendLine}.`;
|
||||
}
|
||||
const lines = [`Advisors enabled (${stats.advisors.length}):`];
|
||||
@@ -16968,7 +16968,7 @@ export class AgentSession {
|
||||
? `${s.contextTokens.toLocaleString()} / ${s.contextWindow.toLocaleString()} (${Math.round((s.contextTokens / s.contextWindow) * 100)}%)`
|
||||
: `${s.contextTokens.toLocaleString()}`;
|
||||
lines.push(
|
||||
` • ${s.name}${s.model ? ` (${s.model.provider}/${s.model.id})` : ` [${s.status}]`} — context ${ctx} tokens, $${s.cost.toFixed(4)}`,
|
||||
` • ${s.name}${s.model && s.status === "running" ? ` (${s.model.provider}/${s.model.id})` : ` [${s.status}]`} — context ${ctx} tokens, $${s.cost.toFixed(4)}`,
|
||||
);
|
||||
}
|
||||
lines.push(
|
||||
|
||||
@@ -284,4 +284,16 @@ describe("AgentSession advisor toggle", () => {
|
||||
expect(sessionB.isAdvisorEnabled()).toBe(true);
|
||||
expect(sessionB.isAdvisorActive()).toBe(true);
|
||||
});
|
||||
|
||||
it("exposes provider sessionId on live advisor stats", () => {
|
||||
session.settings.setModelRole("advisor", `${model.provider}/${model.id}`);
|
||||
session.toggleAdvisorEnabled();
|
||||
|
||||
const stats = session.getAdvisorStats();
|
||||
expect(stats.advisors).toHaveLength(1);
|
||||
const sid = stats.advisors[0].sessionId!;
|
||||
// Full UUIDv7 — must not contain the display-label "-advisor" suffix
|
||||
expect(sid).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i);
|
||||
expect(sid).not.toContain("-advisor");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user