惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
爱范儿
爱范儿
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
J
Java Code Geeks
宝玉的分享
宝玉的分享
Jina AI
Jina AI
B
Blog
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
腾讯CDC
C
Check Point Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky
罗磊的独立博客
B
Blog RSS Feed
WordPress大学
WordPress大学
小众软件
小众软件
博客园 - 叶小钗
M
MIT News - Artificial intelligence
GbyAI
GbyAI

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(status): show 0 (not ?) for fresh-session context tok...
Alix-007 · 2026-06-17 · via Recent Commits to openclaw:main

@@ -443,6 +443,8 @@ describe("initSessionState thread forking", () => {

443443

expect(result.sessionKey).toBe(threadSessionKey);

444444

expect(result.sessionEntry.sessionId).not.toBe(parentSessionId);

445445

expect(result.sessionEntry.displayName).toBe(threadLabel);

446+

expect(result.sessionEntry.totalTokens).toBeUndefined();

447+

expect(result.sessionEntry.totalTokensFresh).toBe(false);

446448447449

const newSessionFile = requireString(

448450

result.sessionEntry.sessionFile,

@@ -512,6 +514,8 @@ describe("initSessionState thread forking", () => {

512514

[threadSessionKey]: {

513515

sessionId: "preseed-thread-session",

514516

updatedAt: Date.now(),

517+

totalTokens: 0,

518+

totalTokensFresh: true,

515519

},

516520

});

517521

@@ -531,6 +535,8 @@ describe("initSessionState thread forking", () => {

531535532536

expect(first.sessionEntry.sessionId).not.toBe("preseed-thread-session");

533537

expect(first.sessionEntry.forkedFromParent).toBe(true);

538+

expect(first.sessionEntry.totalTokens).toBeUndefined();

539+

expect(first.sessionEntry.totalTokensFresh).toBe(false);

534540535541

const second = await initSessionState({

536542

ctx: {

@@ -544,6 +550,8 @@ describe("initSessionState thread forking", () => {

544550545551

expect(second.sessionEntry.sessionId).toBe(first.sessionEntry.sessionId);

546552

expect(second.sessionEntry.forkedFromParent).toBe(true);

553+

expect(second.sessionEntry.totalTokens).toBeUndefined();

554+

expect(second.sessionEntry.totalTokensFresh).toBe(false);

547555

warn.mockRestore();

548556

});

549557

@@ -614,6 +622,8 @@ describe("initSessionState thread forking", () => {

614622

expect(result.sessionEntry.sessionId).not.toBe(parentSessionId);

615623

// Session file should NOT be the parent's file (it was not forked)

616624

expect(result.sessionEntry.sessionFile).not.toBe(parentSessionFile);

625+

expect(result.sessionEntry.totalTokens).toBe(0);

626+

expect(result.sessionEntry.totalTokensFresh).toBe(true);

617627

});

618628619629

it("skips fork when resolved parent token estimate exceeds threshold", async () => {

@@ -848,7 +858,8 @@ describe("initSessionState RawBody", () => {

848858

expect(result.resetTriggered).toBe(true);

849859

expect(result.sessionId).not.toBe(existingSessionId);

850860

expect(result.sessionEntry.skillsSnapshot).toBeUndefined();

851-

expect(result.sessionEntry.totalTokens).toBeUndefined();

861+

expect(result.sessionEntry.totalTokens).toBe(0);

862+

expect(result.sessionEntry.totalTokensFresh).toBe(true);

852863

expect(result.sessionEntry.contextTokens).toBeUndefined();

853864

expect(result.sessionEntry.contextBudgetStatus).toBeUndefined();

854865

@@ -857,12 +868,14 @@ describe("initSessionState RawBody", () => {

857868

{

858869

skillsSnapshot?: unknown;

859870

totalTokens?: number;

871+

totalTokensFresh?: boolean;

860872

contextTokens?: number;

861873

contextBudgetStatus?: unknown;

862874

}

863875

>;

864876

expect(store[sessionKey]?.skillsSnapshot).toBeUndefined();

865-

expect(store[sessionKey]?.totalTokens).toBeUndefined();

877+

expect(store[sessionKey]?.totalTokens).toBe(0);

878+

expect(store[sessionKey]?.totalTokensFresh).toBe(true);

866879

expect(store[sessionKey]?.contextTokens).toBeUndefined();

867880

expect(store[sessionKey]?.contextBudgetStatus).toBeUndefined();

868881

});

@@ -3047,9 +3060,9 @@ describe("initSessionState preserves behavior overrides across /new and /reset",

30473060

expect(result.sessionEntry.modelOverrideSource).toBeUndefined();

30483061

expect(result.sessionEntry.modelOverrideFallbackOriginProvider).toBeUndefined();

30493062

expect(result.sessionEntry.modelOverrideFallbackOriginModel).toBeUndefined();

3050-

expect(result.sessionEntry.totalTokens).toBeUndefined();

3063+

expect(result.sessionEntry.totalTokens).toBe(0);

30513064

expect(result.sessionEntry.contextTokens).toBeUndefined();

3052-

expect(result.sessionEntry.totalTokensFresh).toBeUndefined();

3065+

expect(result.sessionEntry.totalTokensFresh).toBe(true);

30533066

});

3054306730553068

it("preserves spawned session ownership metadata across /new and /reset", async () => {

@@ -3635,6 +3648,59 @@ describe("persistSessionUsageUpdate", () => {

36353648

expect(stored[sessionKey].outputTokens).toBe(10_000);

36363649

});

363736503651+

it("marks a fresh zero stale when a completed run has no context snapshot", async () => {

3652+

const storePath = await createStorePath("openclaw-usage-no-snapshot-");

3653+

const sessionKey = "main";

3654+

await seedSessionStore({

3655+

storePath,

3656+

sessionKey,

3657+

entry: {

3658+

sessionId: "s1",

3659+

updatedAt: Date.now(),

3660+

totalTokens: 0,

3661+

totalTokensFresh: true,

3662+

},

3663+

});

3664+3665+

await persistSessionUsageUpdate({

3666+

storePath,

3667+

sessionKey,

3668+

modelUsed: "claude-sonnet-4-6",

3669+

contextTokensUsed: 200_000,

3670+

});

3671+3672+

const stored = JSON.parse(await fs.readFile(storePath, "utf-8"));

3673+

expect(stored[sessionKey].totalTokens).toBe(0);

3674+

expect(stored[sessionKey].totalTokensFresh).toBe(false);

3675+

});

3676+3677+

it("preserves fresh post-compaction totalTokens across model-only updates", async () => {

3678+

const storePath = await createStorePath("openclaw-usage-no-snapshot-");

3679+

const sessionKey = "main";

3680+

await seedSessionStore({

3681+

storePath,

3682+

sessionKey,

3683+

entry: {

3684+

sessionId: "s1",

3685+

updatedAt: Date.now(),

3686+

totalTokens: 42_000,

3687+

totalTokensFresh: true,

3688+

},

3689+

});

3690+3691+

await persistSessionUsageUpdate({

3692+

storePath,

3693+

sessionKey,

3694+

modelUsed: "claude-sonnet-4-6",

3695+

contextTokensUsed: 200_000,

3696+

preserveFreshTotalTokensOnStaleUsage: true,

3697+

});

3698+3699+

const stored = JSON.parse(await fs.readFile(storePath, "utf-8"));

3700+

expect(stored[sessionKey].totalTokens).toBe(42_000);

3701+

expect(stored[sessionKey].totalTokensFresh).toBe(true);

3702+

});

3703+36383704

it("accounts exhausted-run usage without committing its model", async () => {

36393705

const storePath = await createStorePath("openclaw-usage-exhausted-");

36403706

const sessionKey = "main";