Repository navigation
Description
Summary
On OpenClaw 2026.5.6, a dedicated Codex agent using the native Codex runtime is much slower than the native Codex App/CLI experience on the same machine. Even a fresh, explicit --agent codex session that only replies OK took 25.9s and sent about 33k prompt tokens.
This makes the OpenClaw Codex harness feel unusable for interactive chat compared with Codex App/CLI. I previously switched back to PI for this reason, and after retesting on 2026.5.6 the issue still reproduces.
There is also a documentation mismatch: the public docs page currently shows codex/gpt-* in the quick config, while the installed 2026.5.6 docs say new native Codex configs should use openai/gpt-* + agentRuntime.id: "codex" and that codex/gpt-* is a legacy alias.
Environment
- OpenClaw version:
2026.5.6 - Platform: macOS
26.4.1, arm64 - Gateway: LaunchAgent, local gateway on
127.0.0.1:18789 - Codex auth: local Codex/Codex OAuth is available; direct Codex App/CLI is much faster on the same machine/account
- Workspace: existing OpenClaw workspace with Feishu, Weixin, memory-core/gbrain enabled
Config tested
Dedicated codex agent, leaving main on PI:
{
"id": "codex",
"name": "小K Codex",
"workspace": "/Users/yu/.openclaw/workspace",
"model": {
"primary": "openai/gpt-5.5",
"fallbacks": ["openai/gpt-5.4-mini"]
},
"agentRuntime": {
"id": "codex"
}
}main was kept on PI:
{
"id": "main",
"model": {
"primary": "openai-codex/gpt-5.5",
"fallbacks": ["openai-codex/gpt-5.4-mini"]
},
"agentRuntime": {
"id": "pi"
}
}Reproduction
Run a clean explicit Codex-agent session:
openclaw agent \
--agent codex \
--session-id codex-native-smoke-$(date +%s) \
--message '[local diagnostic] 只回复 OK,用于确认独立 codex agent native runtime。' \
--thinking off \
--json \
--timeout 90Observed result
The request succeeds, but latency is very high:
{
"status": "ok",
"result": {
"meta": {
"durationMs": 25908,
"agentMeta": {
"provider": "openai",
"model": "gpt-5.5",
"contextTokens": 272000,
"agentHarnessId": "codex",
"usage": {
"input": 29779,
"output": 17,
"cacheRead": 3456,
"total": 33252
},
"promptTokens": 33235
},
"executionTrace": {
"winnerProvider": "openai",
"winnerModel": "gpt-5.5",
"attempts": [
{
"provider": "openai",
"model": "gpt-5.5",
"result": "success",
"stage": "assistant"
}
],
"fallbackUsed": false,
"runner": "embedded"
},
"requestShaping": {
"thinking": "off"
}
}
}
}Status after the run shows the same:
agentId: codex
runtime: OpenAI Codex
model: gpt-5.5
inputTokens: 29779
outputTokens: 17
totalTokens: 33235
There was no fallback. The route appears to be the native Codex runtime, but the trivial turn still takes ~26 seconds.
Expected result
For a fresh Codex agent session with thinking: off and a trivial reply OK prompt, OpenClaw native Codex runtime should be much closer to Codex App/CLI latency on the same machine. If OpenClaw must inject ~30k tokens of tool/channel/workspace context into every fresh native Codex runtime turn, there should be a documented way to run a lean Codex agent profile for interactive use.
Additional observations
- Setting lower bootstrap budgets did not materially reduce the native Codex runtime prompt size. The prompt remained around ~33k tokens, suggesting the dominant cost is the OpenClaw tool/runtime/channel context rather than workspace bootstrap files.
- PI remains faster/more usable for day-to-day OpenClaw chat on this setup, even though it still carries a large prompt.
- Related but not identical: [Feature]: Split /fast for openai-codex/* into latency-only vs aggressive profiles #45570 discusses
/fastbehavior foropenai-codex/*; this issue is specifically about the native Codex runtime path (agentRuntime.id: "codex") on a dedicated agent.
Documentation mismatch
The public docs page at:
https://docs.openclaw.ai/plugins/codex-harness#quick-config
currently shows quick config using codex/gpt-5.4 and embeddedHarness.runtime: "codex".
The installed docs in the 2026.5.6 package say:
- new native Codex runtime configs should use
openai/gpt-*withagentRuntime.id: "codex" codex/gpt-*refs are legacy compatibility aliasesopenai-codex/gpt-*is the PI Codex OAuth/subscription path
It would help to clarify which config shape is canonical for 2026.5.6+, and whether embeddedHarness vs agentRuntime is current or legacy naming.
Request
Could you please clarify whether this latency is expected for the native Codex runtime, and whether there is a supported lean profile or config knob to reduce the per-turn prompt/tool schema overhead for a dedicated Codex agent?
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon May 7, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.
Summary
Keep open: current main and hosted docs now agree on the canonical Codex model/runtime shape, but there is still no current-main proof that trivial native Codex turns are fast enough or that OpenClaw has a documented lean interactive profile.
Reproducibility: no. high-confidence current-main live reproduction was established. The reporter and commenter provided concrete 2026.5.6 timing data, and current source still shows the relevant context/tool assembly path, but a fresh native Codex OAuth smoke is still needed.
Next step
Needs maintainer performance/product judgment and a real current-main native Codex OAuth smoke before a safe fix boundary is clear.
Review details
Best possible solution:
Measure a fresh native Codex smoke on current main, then either document the existing knobs as the supported lean recipe with tradeoffs or design a first-class lean Codex profile.
Do we have a high-confidence way to reproduce the issue?
No high-confidence current-main live reproduction was established. The reporter and commenter provided concrete 2026.5.6 timing data, and current source still shows the relevant context/tool assembly path, but a fresh native Codex OAuth smoke is still needed.
Is this the best way to solve the issue?
No, closing as implemented would only cover the docs-prefix portion. The maintainable path is to decide, with measurements, whether existing
codexDynamicToolsExclude/serviceTierbehavior is sufficient or whether a named lean profile is needed.Acceptance criteria:
openclaw agent --agent codex --session-id codex-native-smoke-$(date +%s) --message '[local diagnostic] reply exactly OK' --thinking off --json --timeout 90and record latency plus prompt-token totals.node scripts/run-vitest.mjs extensions/codex/src/app-server/run-attempt.test.ts extensions/codex/src/app-server/dynamic-tools.test.ts.What I checked:
openai/gpt-*model refs, say not to configureopenai-codex/gpt-*, and describeagentRuntime.id: "codex"as the runtime selector, which resolves the original docs-prefix mismatch. Public docs:docs/plugins/codex-harness.md. (docs/plugins/codex-harness.md:19, ea16a5e9e10c)openai/gpt-*andagentRuntime.id: "codex"guidance and no longer shows the stale quick-config shape from the report.extensions/codex/src/app-server/run-attempt.ts:534, ea16a5e9e10c)codexDynamicToolsExclude, but they do not define a first-class lean latency profile or target for trivial interactive turns. Public docs:docs/plugins/codex-harness.md. (docs/plugins/codex-harness.md:472, ea16a5e9e10c)/fastissue was closed because fast mode no longer reduces reasoning quality.Likely related people:
run-attempt.tsand Codex harness docs near this latency/runtime surface. (role: Codex app-server feature owner / recent area contributor; confidence: high; commits: dd26e8c44d4e, 934fc6ceeb10, 1e31bd2ac29d; files:extensions/codex/src/app-server/run-attempt.ts,docs/plugins/codex-harness.md)docs/providers/openai.md,extensions/codex/src/app-server/dynamic-tools.ts)fix(codex): scope user MCP servers by agentwork. (role: recent Codex docs/tool-scope contributor; confidence: medium; commits: 472523360d88; files:docs/plugins/codex-harness.md,docs/providers/openai.md,extensions/codex/src/app-server/dynamic-tool-profile.ts)docs/providers/openai.md,extensions/codex/src/app-server)Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against ea16a5e9e10c.
kesslerio commentedon May 7, 2026
I saw the same general Codex latency problem during a 2026.5.6 live test.
A trivial Codex harness smoke (
reply exactly CODEX_OK) usingopenai-codex/gpt-5.5completed, but took about 22s. That is much slower than the native Codex CLI/app experience on the same host.More importantly, during the live trial the gateway later hit event-loop starvation while channel traffic was active. I would not claim Codex alone caused that, but the Codex harness path is definitely part of the load profile that makes the gateway feel fragile.
crash2kx commentedon May 20, 2026
I can add a source-level and timing update from another affected self-hosted setup. This looks like more than model latency or Docker overhead: the Codex app-server client is warm, but the OpenClaw Codex harness still spends several seconds per turn rebuilding auth/startup/tool state before the prompt is submitted.
Environment:
2026.5.18/ commit50a2481openai-codex/gpt-5.5Measured warm-turn trace from local instrumentation:
Important detail: the shared Codex app-server client was reused on the warm turn:
So in this case the expensive part is not a full app-server cold start. The cache works, but the code appears to do expensive setup before it reaches the cache hit.
Source review against the current tree matches the trace:
extensions/codex/src/app-server/run-attempt.tsresolveCodexAppServerAuthAccountCacheKey(...)is awaited every turn before tool build / startup.buildDynamicTools(...)is also called every turn.extensions/codex/src/app-server/shared-client.tsgetSharedCodexAppServerClient(...)resolvesauthProfileId,resolveManagedCodexAppServerStartOptions(...), andbridgeCodexAppServerStartOptions(...)before looking up the shared-client map.extensions/codex/src/app-server/auth-bridge.tsresolveCodexAppServerAuthProfileIdForAgent(...)callsensureCodexAppServerAuthProfileStore(...)andresolveAuthProfileOrder(...).bridgeCodexAppServerStartOptions(...)callsensureCodexAppServerAuthProfileStore(...)again and checks whether inherited OpenAI API-key env should be cleared.This also explains why Codex App/CLI on the same account can feel much faster: in the measured OpenClaw warm turn the model/Codex completion was only about 3 seconds, while OpenClaw spent about 7.5 seconds preparing the turn before
prompt.submitted.Possible fix direction:
agentDir + authProfileId + authProfileStore/config fingerprint, with invalidation when auth/config changes.auth_profile.resolveandbridge_options.resolveon every turn.agentId/sessionKey/model/tool allowlist/plugin configinputs, or split static tool schema construction from per-turn message/channel context.auth_cache,dynamic_tools.build,client_factory.pre_lookup,client_factory.cache_hit,prompt.submitted,completion.wait) so operators can distinguish model latency from OpenClaw harness overhead.This is related to #84037 and #84662, but this specific measurement is about per-turn warm-path overhead before prompt submission, even when the app-server shared client is already alive and reused.
blurry-clouds commentedon May 23, 2026
Adding a reproduction from OpenClaw
2026.5.20 (e510042)that seems to fit this issue rather than warranting a separate one.I tested a Discord-oriented
chatagent using native Codex runtime (openai/gpt-5.5,agentHarnessId: codex). The agent config is intentionally small:thinkingDefault: low,fastModeDefault: true,contextInjection: "never",skills: [], and a messaging-only tool profile.Observed behavior:
169kinput tokens, mostly cached, against a reported272kCodex context window. This was not a fresh-session baseline; it included accumulated diagnostic history.22k-23kprompt tokens.contextInjection: "never"appears scoped to workspace bootstrap injection; it does not disable Codex context-engine/tool/MCP projection.I tested candidate knobs in temporary configs without mutating the live config:
agents.list[].contextTokens = 8192openclaw config getshowedchat.contextTokens: 8192.OPENCLAW_CONFIG_PATH=$tmp openclaw agent --local --agent chat --message 'Runtime dry-run: reply with exactly OK.' --jsonstill reportedmeta.agentMeta.contextTokens: 272000and Codex context-engine projection logs.22k-23ktokens.bootstrapMaxChars = 1andbootstrapTotalMaxChars = 122ktokens.agents.list[].experimental.localModelLean = truebrowser,cron, andmessage.messagedisappeared from the tool list, butsessions_list,sessions_history,sessions_send, andsession_statusremained.meta.agentMeta.contextTokensstayed272000, and prompt remained around23ktokens.I have not found a documented supported way to run a genuinely lean native Codex chat agent. The available knobs seem to affect bootstrap only, local-model tool trimming only, or session/status context accounting, but not the Codex app-server context-engine/tool/MCP projection envelope.
Clarifications that would help:
agents.list[].contextTokensintended to affect native CodexcontextTokenBudget/ projection sizing?agentMeta.contextTokensonly the model/runtime context window rather than a configured cap?steipete commentedon May 31, 2026
Thanks for the report. Closing as stale after the canonical route docs and provider unification.
The docs-prefix disagreement is resolved by using canonical
openai/gpt-*refs for Codex runtime. Please file a fresh issue with current-build latency proof if trivial turns are still slow on canonicalopenai/gpt-*afteropenclaw doctor --fix.