Skip to content

Use native Codex side threads and OpenAI auth fallback#80493

Merged
steipete merged 26 commits into
mainfrom
codex/codex-native-btw-side-thread
May 11, 2026
Merged

Use native Codex side threads and OpenAI auth fallback#80493
steipete merged 26 commits into
mainfrom
codex/codex-native-btw-side-thread

Conversation

@pashpashpash

@pashpashpash pashpashpash commented May 11, 2026

Copy link
Copy Markdown
Contributor

OpenClaw already treats /side as an alias for /btw, but the implementation was still a generic one-shot provider call. That was fine for API-key providers, but it is the wrong transport once openai/gpt-5.5 is running through the Codex harness with a Codex OAuth profile: the side question falls through to plain OpenAI Responses auth, where the token can fail with missing api.responses.write scopes.

This change adds a small optional side-question hook to agent harnesses and implements it for the Codex app-server harness. When /btw or /side is routed to Codex, OpenClaw now forks the bound Codex thread as an ephemeral side thread, injects a side-conversation boundary, starts the side turn there, returns the answer as the existing chat.side_result payload, and unsubscribes afterward. The Codex path stays native for auth and thread context, but it preserves the existing /btw contract: the side turn is tool-free, read-only, and outside the parent transcript. PI and non-Codex providers keep the existing direct lightweight path.

If there is no Codex parent thread yet, OpenClaw now fails clearly and asks the user to send a normal message first instead of silently trying public OpenAI auth.

While touching the same routing area, this also makes OpenAI/Codex auth ordering less weird. New config can put Codex-compatible OAuth and API-key profiles under auth.order.openai, while existing openai-codex:* profiles and auth.order.openai-codex keep working. That gives users the obvious subscription-first, API-key-backup shape without forcing a migration.

The account command now explains that setup in the terms users actually care about. If the ChatGPT subscription is active, /codex account says Codex is running on the subscription, shows the readable subscription usage windows, and lists the configured backup. If the subscription is paused and OpenClaw has moved to an API key, it says the API-key backup is active, why the subscription was skipped, when OpenClaw will try it again, and shows the full ordered ladder without raw bucket names, primary/secondary, or openai-codex naming.

Fixes #80469.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: codex size: XL maintainer Maintainer-authored PR labels May 11, 2026
@clawsweeper

clawsweeper Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR adds a Codex harness side-question hook, routes Codex /btw through ephemeral app-server side threads, expands OpenAI/Codex auth fallback ordering, updates /codex account output, and adds docs/tests.

Reproducibility: yes. at source level, not live in this review. Current main routes /btw through generic provider auth/streaming and the linked issue gives the Codex OAuth api.responses.write failure path.

Real behavior proof
Needs stronger real behavior proof before merge: Mantis proof shows real Telegram /btw replies before and after, but it does not show the Codex OAuth/native side-thread diagnostics or account fallback behavior changed by this PR. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, ask a maintainer to comment @clawsweeper re-review.

Next step before merge
This maintainer-labeled PR should stay in human review until maintainers approve the Codex side-thread/auth policy and the contributor adds redacted proof of the changed native transport and fallback behavior.

Security
Cleared: No concrete security or supply-chain regression was found in the diff; the auth and side-thread permission policy still needs maintainer review.

Review details

Best possible solution:

Land the Codex-native /btw fix after maintainer approval, keeping the side-thread/auth policy deliberate and adding redacted live proof that shows the native Codex transport plus account fallback behavior.

Do we have a high-confidence way to reproduce the issue?

Yes at source level, not live in this review. Current main routes /btw through generic provider auth/streaming and the linked issue gives the Codex OAuth api.responses.write failure path.

Is this the best way to solve the issue?

Mostly yes. Moving Codex /btw into a harness-native side thread is the right owner-boundary fix, but native tool semantics and API-key fallback ordering need maintainer approval and stronger real proof.

Acceptance criteria:

  • pnpm test src/agents/btw.test.ts extensions/codex/src/app-server/side-question.test.ts extensions/codex/src/app-server/auth-bridge.test.ts src/agents/auth-profiles/order.test.ts extensions/codex/src/commands.test.ts
  • pnpm test src/agents/pi-embedded-runner/run.overflow-compaction.test.ts src/agents/runtime-plan/build.test.ts src/agents/auth-profiles/session-override.test.ts src/agents/auth-profiles/usage.test.ts extensions/openai/openai-codex-provider.test.ts extensions/openai/openclaw.plugin.test.ts
  • pnpm tsgo:extensions
  • pnpm tsgo:extensions:test
  • Redacted live proof showing Codex OAuth/native side-thread /btw and /codex account fallback behavior, with private IPs, keys, phone numbers, and non-public endpoints removed.

What I checked:

  • current-main-btw-generic-path: Current main still resolves /btw through the generic model/auth path and calls getApiKeyForModel before provider streaming, so Codex-backed OpenAI side questions can bypass the Codex harness transport. (src/agents/btw.ts:337, c2a13e292f98)
  • current-main-codex-harness-no-side-hook: Current main's Codex harness exposes runAttempt, compact, reset, and dispose, but no side-question hook for native /btw handling. (extensions/codex/harness.ts:39, c2a13e292f98)
  • pr-routes-btw-through-harness: The PR selects the active harness before generic fallback and calls harness.runSideQuestion when available; it fails closed when the Codex harness lacks side-question support. (src/agents/btw.ts:315, da472e0af830)
  • pr-codex-native-side-thread: The PR's Codex implementation reads the parent app-server binding, forks an ephemeral child thread, injects a side boundary, starts a turn, collects the answer, and unsubscribes or interrupts during cleanup. (extensions/codex/src/app-server/side-question.ts:78, da472e0af830)
  • pr-auth-order-support: The PR treats normal OpenAI API-key credentials as Codex-compatible backups when resolving Codex app-server auth profiles. (extensions/codex/src/app-server/auth-bridge.ts:423, da472e0af830)
  • telegram-proof-insufficient-for-native-path: The Mantis artifacts show real Telegram before/after /btw replies, but the visible screenshots/reports do not show Codex OAuth, native side-thread diagnostics, or /codex account fallback behavior; the baseline screenshot visibly reports the old PI/default runtime status. (da472e0af830)

Likely related people:

  • steipete: Current-main blame and recent local history show Peter Steinberger on the affected /btw and Codex auth/app-server paths, and this PR also contains steipete follow-up commits in the side-thread/auth area. (role: recent Codex app-server and /btw area contributor; confidence: high; commits: 37fa027772bb, ffba41fe6b86, be0e85a72ddb; files: src/agents/btw.ts, extensions/codex/harness.ts, extensions/codex/src/app-server/auth-bridge.ts)
  • pashpashpash: GitHub commit history for src/agents/btw.ts shows prior merged OpenAI/Codex runtime-routing work by pashpashpash, and the current PR branch implements the proposed side-thread/auth fallback changes. (role: OpenAI/Codex routing area contributor; confidence: high; commits: 1c3399010815, 02fe0d8978db, a2ae97c4ee7e; files: src/agents/btw.ts, src/agents/runtime-plan/auth.ts, src/agents/auth-profiles/order.ts)
  • kevinslin: Recent GitHub history for the Codex app-server auth path shows native plugin app support work that is adjacent to the side-thread tool and native app policy surface touched here. (role: adjacent Codex native app contributor; confidence: medium; commits: a1ac559ed7e6; files: extensions/codex/src/app-server/auth-bridge.ts, extensions/codex/src/app-server/side-question.ts)

Remaining risk / open question:

  • The posted real proof shows visible Telegram replies but not the changed Codex OAuth/native side-thread transport or /codex account fallback path.
  • Side-thread native tool availability and OpenAI API-key fallback ordering are maintainer-labeled policy surfaces that should be explicitly approved.

Codex review notes: model gpt-5.5, reasoning high; reviewed against c2a13e292f98.

@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 11, 2026
@pashpashpash
pashpashpash requested a review from a team as a code owner May 11, 2026 02:26
@pashpashpash
pashpashpash force-pushed the codex/codex-native-btw-side-thread branch from 1be72ce to 532e4c7 Compare May 11, 2026 03:09
@clawsweeper clawsweeper Bot removed the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 11, 2026
@pashpashpash

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@pashpashpash

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

To use Codex here, create a Codex account and connect to github.

@pashpashpash

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@pashpashpash

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@pashpashpash

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 11, 2026
@pashpashpash
pashpashpash force-pushed the codex/codex-native-btw-side-thread branch from 3b0d2fb to 2115d85 Compare May 11, 2026 04:37
@clawsweeper

clawsweeper Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@pashpashpash pashpashpash changed the title Route Codex side questions through native side threads Use native Codex side threads and OpenAI auth fallback May 11, 2026
@clawsweeper

clawsweeper Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@pashpashpash
pashpashpash force-pushed the codex/codex-native-btw-side-thread branch 2 times, most recently from 6248533 to 803c973 Compare May 11, 2026 05:19
@pashpashpash
pashpashpash force-pushed the codex/codex-native-btw-side-thread branch from 10202aa to da472e0 Compare May 11, 2026 11:14
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label May 11, 2026
@steipete steipete added the proof: override Maintainer override for the external PR real behavior proof gate. label May 11, 2026
@steipete
steipete merged commit 2846d9e into main May 11, 2026
115 of 117 checks passed
@steipete
steipete deleted the codex/codex-native-btw-side-thread branch May 11, 2026 11:41
@steipete

Copy link
Copy Markdown
Contributor

Landed via GitHub rebase merge onto main.

Proof:

  • PR head pushed: da472e0
  • Local ship sanity: git diff --check refs/remotes/origin/pr/80493
  • Targeted fix proof from the pushed branch: pnpm test extensions/codex/src/app-server/rate-limits.test.ts src/agents/auth-profiles/order.test.ts -- --reporter=verbose
  • Earlier branch proof while addressing review feedback: pnpm test extensions/codex/src/app-server/rate-limits.test.ts src/agents/auth-profiles/session-override.test.ts src/agents/auth-profiles/order.test.ts -- --reporter=verbose, pnpm tsgo:core, pnpm tsgo:extensions
  • GitHub checks: passing, including Real behavior proof after maintainer proof: override
  • Merge commit: 2846d9e

Thanks @pashpashpash!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: zalouser Channel integration: zalouser cli CLI command changes docs Improvements or additions to documentation extensions: codex extensions: openai maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. proof: override Maintainer override for the external PR real behavior proof gate. size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/btw uses plain OpenAI Responses with Codex OAuth instead of active Codex transport

3 participants