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

推荐订阅源

J
Java Code Geeks
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
B
Blog
aimingoo的专栏
aimingoo的专栏
酷 壳 – CoolShell
酷 壳 – CoolShell
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
月光博客
月光博客
H
Help Net Security
V
Visual Studio Blog
量子位
A
About on SuperTechFans
博客园 - Franky
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
P
Proofpoint News Feed
MongoDB | Blog
MongoDB | Blog

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(codex): honor OAuth contextTokens in native harness ·...
lilesjtu · 2026-05-06 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -143,6 +143,7 @@ Docs: https://docs.openclaw.ai

143143

- Agents/media: avoid direct generated-media completion fallback while the announce-agent run is still pending, so async video and music completions do not duplicate raw media messages. (#77754)

144144

- WebChat/Codex media: stage Codex app-server generated local images into managed media before Gateway display, so Codex-home image paths no longer hit `LocalMediaAccessError` while keeping Codex home out of the display allowlist. Thanks @frankekn.

145145

- Plugins/update: repair plugin-local `openclaw` peer links for all recorded npm plugins after any npm update mutates the shared managed npm tree, so targeted or batch updates cannot leave Codex, Discord, or Brave with pruned SDK imports. (#77787) Thanks @ProspectOre.

146+

- Codex harness: honor `models.providers.openai-codex.models[].contextTokens` for native `openai/*` Codex runtime runs and `/status` context reporting, so subscription-backed Codex agents use the configured OAuth context cap without inflating past the runtime model window. Fixes #77858. Thanks @lilesjtu.

146147

- TUI/sessions: bound the session picker to recent rows and use exact lookup-style refreshes for the active session, so dusty stores no longer make TUI hydrate weeks-old transcripts before becoming responsive. Thanks @vincentkoc.

147148

- Doctor/gateway: report recent supervisor restart handoffs in `openclaw doctor --deep`, using the installed service environment when available so service-managed clean exits are visible in guided diagnostics. Thanks @shakkernerd.

148149

- Gateway/status: show recent supervisor restart handoffs in `openclaw gateway status --deep`, including JSON details, so clean service-managed restarts are reported as restart handoffs instead of opaque stopped-service diagnostics. Thanks @shakkernerd.

Original file line numberDiff line numberDiff line change

@@ -35,6 +35,7 @@ type DiscoveredModel = {

3535

name?: string;

3636

provider: string;

3737

contextWindow?: number;

38+

contextTokens?: number;

3839

reasoning?: boolean;

3940

input?: ModelInputType[];

4041

compat?: ModelCatalogEntry["compat"];

@@ -161,6 +162,9 @@ export function loadManifestModelCatalog(params: {

161162

if (contextWindow) {

162163

entry.contextWindow = contextWindow;

163164

}

165+

if (row.contextTokens) {

166+

entry.contextTokens = row.contextTokens;

167+

}

164168

if (typeof row.reasoning === "boolean") {

165169

entry.reasoning = row.reasoning;

166170

}

@@ -189,6 +193,7 @@ function normalizePersistedModelCatalogEntry(

189193

entry: Record<string, unknown>,

190194

defaults?: {

191195

contextWindow?: number;

196+

contextTokens?: number;

192197

},

193198

): ModelCatalogEntry | undefined {

194199

const id = normalizeOptionalString(entry.id) ?? "";

@@ -206,6 +211,12 @@ function normalizePersistedModelCatalogEntry(

206211

: defaults?.contextWindow !== undefined

207212

? defaults.contextWindow

208213

: PI_CUSTOM_MODEL_DEFAULT_CONTEXT_WINDOW;

214+

const contextTokens =

215+

typeof entry?.contextTokens === "number" && entry.contextTokens > 0

216+

? entry.contextTokens

217+

: defaults?.contextTokens !== undefined

218+

? defaults.contextTokens

219+

: undefined;

209220

const reasoning = typeof entry?.reasoning === "boolean" ? entry.reasoning : false;

210221

const parsedInput = Array.isArray(entry?.input)

211222

? entry.input.filter((value): value is ModelInputType =>

@@ -217,7 +228,16 @@ function normalizePersistedModelCatalogEntry(

217228

entry?.compat && typeof entry.compat === "object"

218229

? (entry.compat as ModelCatalogEntry["compat"])

219230

: undefined;

220-

return { id, name, provider, contextWindow, reasoning, input, compat };

231+

return {

232+

id,

233+

name,

234+

provider,

235+

contextWindow,

236+

...(contextTokens !== undefined ? { contextTokens } : {}),

237+

reasoning,

238+

input,

239+

compat,

240+

};

221241

}

222242
223243

async function loadReadOnlyPersistedModelCatalog(params?: {

@@ -242,9 +262,14 @@ async function loadReadOnlyPersistedModelCatalog(params?: {

242262

typeof providerConfig?.contextWindow === "number" && providerConfig.contextWindow > 0

243263

? providerConfig.contextWindow

244264

: undefined;

265+

const providerContextTokens =

266+

typeof providerConfig?.contextTokens === "number" && providerConfig.contextTokens > 0

267+

? providerConfig.contextTokens

268+

: undefined;

245269

for (const entry of providerConfig.models as Record<string, unknown>[]) {

246270

const normalized = normalizePersistedModelCatalogEntry(providerRaw, entry, {

247271

contextWindow: providerContextWindow,

272+

contextTokens: providerContextTokens,

248273

});

249274

if (normalized && !shouldSuppressBuiltInModel(normalized)) {

250275

models.push(normalized);

@@ -370,10 +395,23 @@ export async function loadModelCatalog(params?: {

370395

typeof entry?.contextWindow === "number" && entry.contextWindow > 0

371396

? entry.contextWindow

372397

: undefined;

398+

const contextTokens =

399+

typeof entry?.contextTokens === "number" && entry.contextTokens > 0

400+

? entry.contextTokens

401+

: undefined;

373402

const reasoning = typeof entry?.reasoning === "boolean" ? entry.reasoning : undefined;

374403

const input = Array.isArray(entry?.input) ? entry.input : undefined;

375404

const compat = entry?.compat && typeof entry.compat === "object" ? entry.compat : undefined;

376-

models.push({ id, name, provider, contextWindow, reasoning, input, compat });

405+

models.push({

406+

id,

407+

name,

408+

provider,

409+

contextWindow,

410+

...(contextTokens !== undefined ? { contextTokens } : {}),

411+

reasoning,

412+

input,

413+

compat,

414+

});

377415

}

378416

if (!readOnly) {

379417

const supplemental = await augmentModelCatalogWithProviderPlugins({

Original file line numberDiff line numberDiff line change

@@ -8,6 +8,7 @@ export type ModelCatalogEntry = {

88

provider: string;

99

alias?: string;

1010

contextWindow?: number;

11+

contextTokens?: number;

1112

reasoning?: boolean;

1213

input?: ModelInputType[];

1314

compat?: ModelCompatConfig;

Original file line numberDiff line numberDiff line change

@@ -442,6 +442,7 @@ function applyModelCatalogMetadata(params: {

442442

}

443443

const nextAlias = alias ?? params.entry.alias;

444444

const nextContextWindow = configuredEntry?.contextWindow ?? params.entry.contextWindow;

445+

const nextContextTokens = configuredEntry?.contextTokens ?? params.entry.contextTokens;

445446

const nextReasoning = configuredEntry?.reasoning ?? params.entry.reasoning;

446447

const nextInput = configuredEntry?.input ?? params.entry.input;

447448

const nextCompat = configuredEntry?.compat ?? params.entry.compat;

@@ -451,6 +452,7 @@ function applyModelCatalogMetadata(params: {

451452

name: configuredEntry?.name ?? params.entry.name,

452453

...(nextAlias ? { alias: nextAlias } : {}),

453454

...(nextContextWindow !== undefined ? { contextWindow: nextContextWindow } : {}),

455+

...(nextContextTokens !== undefined ? { contextTokens: nextContextTokens } : {}),

454456

...(nextReasoning !== undefined ? { reasoning: nextReasoning } : {}),

455457

...(nextInput ? { input: nextInput } : {}),

456458

...(nextCompat ? { compat: nextCompat } : {}),

@@ -465,6 +467,7 @@ function buildSyntheticAllowedCatalogEntry(params: {

465467

const configuredEntry = params.metadata.configuredByKey.get(key);

466468

const alias = params.metadata.aliasByKey.get(key);

467469

const nextContextWindow = configuredEntry?.contextWindow;

470+

const nextContextTokens = configuredEntry?.contextTokens;

468471

const nextReasoning = configuredEntry?.reasoning;

469472

const nextInput = configuredEntry?.input;

470473

const nextCompat = configuredEntry?.compat;

@@ -475,6 +478,7 @@ function buildSyntheticAllowedCatalogEntry(params: {

475478

provider: params.parsed.provider,

476479

...(alias ? { alias } : {}),

477480

...(nextContextWindow !== undefined ? { contextWindow: nextContextWindow } : {}),

481+

...(nextContextTokens !== undefined ? { contextTokens: nextContextTokens } : {}),

478482

...(nextReasoning !== undefined ? { reasoning: nextReasoning } : {}),

479483

...(nextInput ? { input: nextInput } : {}),

480484

...(nextCompat ? { compat: nextCompat } : {}),

@@ -836,6 +840,10 @@ export function buildConfiguredModelCatalog(params: { cfg: OpenClawConfig }): Mo

836840

typeof model?.contextWindow === "number" && model.contextWindow > 0

837841

? model.contextWindow

838842

: undefined;

843+

const contextTokens =

844+

typeof model?.contextTokens === "number" && model.contextTokens > 0

845+

? model.contextTokens

846+

: undefined;

839847

const reasoning = typeof model?.reasoning === "boolean" ? model.reasoning : undefined;

840848

const input = Array.isArray(model?.input) ? model.input : undefined;

841849

const compat = model?.compat && typeof model.compat === "object" ? model.compat : undefined;

@@ -844,6 +852,7 @@ export function buildConfiguredModelCatalog(params: { cfg: OpenClawConfig }): Mo

844852

id,

845853

name,

846854

contextWindow,

855+

contextTokens,

847856

reasoning,

848857

input,

849858

compat,

Original file line numberDiff line numberDiff line change

@@ -181,6 +181,16 @@ const COMPACTION_CONTINUATION_RETRY_INSTRUCTION =

181181

"The previous attempt compacted the conversation context before producing a final user-visible answer. Continue from the compacted transcript and produce the final answer now. Do not restart from scratch, do not repeat completed work, and do not rerun tools unless the transcript clearly lacks required evidence.";

182182

type EmbeddedRunAttemptForRunner = Awaited<ReturnType<typeof runEmbeddedAttemptWithBackend>>;

183183
184+

function resolveHarnessContextConfigProvider(params: {

185+

provider: string;

186+

harnessId: string;

187+

}): string {

188+

if (params.harnessId === "codex" && params.provider.trim().toLowerCase() === "openai") {

189+

return "openai-codex";

190+

}

191+

return params.provider;

192+

}

193+
184194

function resolveEmbeddedRunLaneTimeoutMs(timeoutMs: number): number | undefined {

185195

if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {

186196

return undefined;

@@ -530,6 +540,10 @@ export async function runEmbeddedPiAgent(

530540

const resolvedRuntimeModel = resolveEffectiveRuntimeModel({

531541

cfg: params.config,

532542

provider,

543+

contextConfigProvider: resolveHarnessContextConfigProvider({

544+

provider,

545+

harnessId: agentHarness.id,

546+

}),

533547

modelId,

534548

runtimeModel,

535549

});

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,12 @@

11

import { describe, expect, it, vi } from "vitest";

2-

import { buildBeforeModelResolveAttachments, resolveHookModelSelection } from "./setup.js";

2+

import type { ModelDefinitionConfig } from "../../../config/types.models.js";

3+

import type { OpenClawConfig } from "../../../config/types.openclaw.js";

4+

import type { ProviderRuntimeModel } from "../../../plugins/provider-runtime-model.types.js";

5+

import {

6+

buildBeforeModelResolveAttachments,

7+

resolveEffectiveRuntimeModel,

8+

resolveHookModelSelection,

9+

} from "./setup.js";

310
411

const hookContext = {

512

sessionId: "session-1",

@@ -73,3 +80,90 @@ describe("resolveHookModelSelection", () => {

7380

);

7481

});

7582

});

83+
84+

function createRuntimeModel(): ProviderRuntimeModel {

85+

return {

86+

provider: "openai",

87+

id: "gpt-5.5",

88+

name: "gpt-5.5",

89+

baseUrl: "https://api.openai.com/v1",

90+

api: "openai-responses",

91+

reasoning: true,

92+

input: ["text", "image"],

93+

cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },

94+

contextWindow: 1_050_000,

95+

contextTokens: 272_000,

96+

maxTokens: 128_000,

97+

};

98+

}

99+
100+

function createConfiguredModel(

101+

overrides: Partial<ModelDefinitionConfig> = {},

102+

): ModelDefinitionConfig {

103+

return {

104+

id: "gpt-5.5",

105+

name: "gpt-5.5",

106+

reasoning: true,

107+

input: ["text", "image"],

108+

cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },

109+

contextWindow: 1_050_000,

110+

contextTokens: 1_000_000,

111+

maxTokens: 128_000,

112+

...overrides,

113+

};

114+

}

115+
116+

describe("resolveEffectiveRuntimeModel", () => {

117+

it("can read Codex OAuth context overrides for native Codex harness runs", () => {

118+

const cfg = {

119+

models: {

120+

providers: {

121+

"openai-codex": {

122+

baseUrl: "https://chatgpt.com/backend-api/codex",

123+

models: [createConfiguredModel()],

124+

},

125+

},

126+

},

127+

} satisfies OpenClawConfig;

128+
129+

const result = resolveEffectiveRuntimeModel({

130+

cfg,

131+

provider: "openai",

132+

contextConfigProvider: "openai-codex",

133+

modelId: "gpt-5.5",

134+

runtimeModel: createRuntimeModel(),

135+

});

136+
137+

expect(result.ctxInfo).toEqual({

138+

source: "modelsConfig",

139+

tokens: 1_000_000,

140+

});

141+

expect(result.effectiveModel.contextWindow).toBe(1_000_000);

142+

});

143+
144+

it("keeps the runtime model contextTokens when no alternate context provider is supplied", () => {

145+

const cfg = {

146+

models: {

147+

providers: {

148+

"openai-codex": {

149+

baseUrl: "https://chatgpt.com/backend-api/codex",

150+

models: [createConfiguredModel()],

151+

},

152+

},

153+

},

154+

} satisfies OpenClawConfig;

155+
156+

const result = resolveEffectiveRuntimeModel({

157+

cfg,

158+

provider: "openai",

159+

modelId: "gpt-5.5",

160+

runtimeModel: createRuntimeModel(),

161+

});

162+
163+

expect(result.ctxInfo).toEqual({

164+

source: "model",

165+

tokens: 272_000,

166+

});

167+

expect(result.effectiveModel.contextWindow).toBe(272_000);

168+

});

169+

});

Original file line numberDiff line numberDiff line change

@@ -117,6 +117,7 @@ export function buildBeforeModelResolveAttachments(

117117

export function resolveEffectiveRuntimeModel(params: {

118118

cfg: OpenClawConfig | undefined;

119119

provider: string;

120+

contextConfigProvider?: string;

120121

modelId: string;

121122

runtimeModel: ProviderRuntimeModel;

122123

}): {

@@ -125,7 +126,7 @@ export function resolveEffectiveRuntimeModel(params: {

125126

} {

126127

const ctxInfo = resolveContextWindowInfo({

127128

cfg: params.cfg,

128-

provider: params.provider,

129+

provider: params.contextConfigProvider ?? params.provider,

129130

modelId: params.modelId,

130131

modelContextTokens: readPiModelContextTokens(params.runtimeModel),

131132

modelContextWindow: params.runtimeModel.contextWindow,

Original file line numberDiff line numberDiff line change

@@ -10,6 +10,7 @@ import {

1010

addSubagentRunForTests,

1111

resetSubagentRegistryForTests,

1212

} from "../../agents/subagent-registry.js";

13+

import type { ModelDefinitionConfig } from "../../config/types.models.js";

1314

import {

1415

completeTaskRunByRunId,

1516

createQueuedTaskRun,

@@ -37,6 +38,16 @@ vi.mock("../../agents/harness/builtin-pi.js", () => ({

3738

}));

3839
3940

const baseCfg = baseCommandTestConfig;

41+

const codexStatusModel: ModelDefinitionConfig = {

42+

id: "gpt-5.5",

43+

name: "GPT-5.5",

44+

reasoning: true,

45+

input: ["text", "image"],

46+

cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },

47+

contextWindow: 1_050_000,

48+

contextTokens: 1_000_000,

49+

maxTokens: 128_000,

50+

};

4051
4152

async function buildStatusReplyForTest(params: { sessionKey?: string; verbose?: boolean }) {

4253

const commandParams = buildCommandTestParams("/status", baseCfg);

@@ -650,6 +661,52 @@ describe("buildStatusReply subagent summary", () => {

650661

);

651662

});

652663
664+

it("uses Codex OAuth context overrides for openai models running on the Codex harness", async () => {

665+

registerStatusCodexHarness();

666+
667+

const text = await buildStatusText({

668+

cfg: {

669+

...baseCfg,

670+

models: {

671+

providers: {

672+

"openai-codex": {

673+

baseUrl: "https://chatgpt.com/backend-api/codex",

674+

models: [codexStatusModel],

675+

},

676+

},

677+

},

678+

agents: {

679+

defaults: {

680+

agentRuntime: { id: "codex" },

681+

},

682+

},

683+

},

684+

sessionEntry: {

685+

sessionId: "sess-status-codex-context",

686+

updatedAt: 0,

687+

totalTokens: 25_000,

688+

},

689+

sessionKey: "agent:main:main",

690+

parentSessionKey: "agent:main:main",

691+

sessionScope: "per-sender",

692+

statusChannel: "mobilechat",

693+

provider: "openai",

694+

model: "gpt-5.5",

695+

resolvedFastMode: false,

696+

resolvedVerboseLevel: "off",

697+

resolvedReasoningLevel: "off",

698+

resolveDefaultThinkingLevel: async () => undefined,

699+

isGroup: false,

700+

defaultGroupActivation: () => "mention",

701+

modelAuthOverride: "oauth",

702+

activeModelAuthOverride: "oauth",

703+

});

704+
705+

const normalized = normalizeTestText(text);

706+

expect(normalized).toContain("Model: openai/gpt-5.5");

707+

expect(normalized).toContain("Context: 25k/1.0m");

708+

});

709+
653710

it("uses workspace-scoped auth evidence in /status auth labels", async () => {

654711

const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-status-auth-label-"));

655712

const workspaceDir = path.join(tempRoot, "workspace");