Skip to content

feat(companion): Codex voice engine on the ChatGPT plan, API under 20 % of quota (#56) - #57

Merged
thomaseude merged 9 commits into
mainfrom
feat/56-codex-voice-engine
Nov 16, 2026
Merged

thomaseude merged 9 commits into
mainfrom
feat/56-codex-voice-engine

Conversation

@thomaseude

@thomaseude thomaseude commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Closes #56

TODO before merge

Done on 2026-10-30, with the service running this branch's build: a session opened on gpt-live-1-codex (one call to chatgpt.com/backend-api/codex/realtime/calls, none to api.openai.com); with minPlanQuotaPercent: 100 the log said no plan engine for device …: 49 % of the plan's quota is left, under 100 % and the session opened on gpt-live-1. config.json is back as it was.

  • On the server: re-run the sed line of the README for the systemd unit (it now sets PATH, so the service finds codex), then systemctl --user daemon-reload && systemctl --user restart t3-voice.
  • From the iPhone, with 20 % or more of the quota left: a session runs on Codex. The log says voice session opened for device … on gpt-live-1-codex, and ~/.codex/logs_2.sqlite shows the call to chatgpt.com/backend-api/codex/realtime/calls.
  • With "minPlanQuotaPercent": 100 in config.json (restart serve): the next session runs on GPT-Live, and the log gives the reason.

What changes

  • codex-live adapter (companion/src/adapters/codex-live/), from the spike of PR research: Codex realtime voice on the ChatGPT plan (spike) #55:
    • CodexLiveEngine, a VoiceEngine: one codex app-server per session, an ephemeral thread (read-only sandbox, approval policy never, no shell, the companion's tools as dynamicTools), realtime v3 over WebRTC with clientManagedHandoffs. The thread's final answer is spoken with thread/realtime/appendSpeech.
    • CodexPlanQuota, a PlanQuota: account/rateLimits/read on a short-lived app-server. It returns the percent left in the 5-hour window and in the week.
    • Each app-server is initialized first. The adapter reads the Codex version from the userAgent of initialize and refuses a version that is not pinned (DEFAULT_CODEX_VERSIONS, 0.163.0). voice.acceptedCodexVersions replaces the list. An app-server that does not answer in 10 s is stopped.
  • Core rule (core/engineChoice.ts, core/voiceSessions.ts): when a session opens, the core reads the quota. With 20 % or more left (the lower of the two limits), the session opens on Codex. Otherwise it opens on GPT-Live: also when the quota is unreadable, a limit is reached, Codex is not pinned or missing, or Codex fails to open the session. The same SDP offer goes to GPT-Live.
  • Accounting: VoiceEngine.billing is usd or plan_quota. Usage records get a billing column (migration 5; older records are usd). Codex minutes cost $0. The daily budget counts API minutes only and never stops a Codex session. When the budget is reached, sessions still open on Codex.
  • Without an OpenAI key, sessions open on Codex while the quota allows, else 503 voice_unavailable.
  • Settings: voice.codexModel (gpt-6.1-terra), voice.codexReasoningEffort (low), voice.minPlanQuotaPercent (20), voice.acceptedCodexVersions.
  • systemd unit: Environment=PATH=@PATH@. Before, the service's PATH had no nvm folder, so it could not find codex.
  • README: the voice engines, the rule, the budget, the Codex versions.
  • Spec Spec: MVP hands-free iOS voice companion for T3 Code #15 is updated: the engines, the quota rule, the server requirements.

Thomas's decisions in this task: the budget blocks the API only; a long answer of the Codex thread is spoken whole; without a key, Codex alone is enough; the Codex pin can be replaced in config.json; tests go through the core (fake quota, two fake engines) and the adapter (fake app-server), never the real Codex.

Checks

  • npm run lint && npm run typecheck && npm test (550 pass) and npm run build.
  • By hand on the VM, with an empty CODEX_HOME (no login): the log reads Codex cannot read the plan's quota: codex answered error -32600; is \codex login` done for this user?`. A Codex error keeps its code only, never its text, which may quote the prompt.
  • By hand on the VM, with the real codex 0.163.0 and without a voice session: the quota read returns {"fiveHourPercentLeft":100,"weekPercentLeft":55,"limitReached":false} in about 1 s. With the pin set to another version, the read is refused. Without codex on the PATH, the error says "the codex binary is not installed".

Cost of the choice

Each session open now starts one more app-server to read the quota, about 1 s before Codex or GPT-Live gets the offer.

🤖 Generated with Claude Code

thomaseude and others added 2 commits October 30, 2026 21:22
…#56)

The core tries the plan engine first when a session opens, and falls
back to the API engine when the quota is low, unreadable or reached, or
when the plan engine fails to open. Minutes on the plan are recorded as
plan_quota at no cost: the daily dollar budget neither counts them nor
stops a session on the plan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dex 0.163.0 (#56)

Adds the codex-live adapter from the spike of PR #55: a VoiceEngine on
codex app-server (one per session, ephemeral read-only thread without a
shell, the companion's tools as dynamicTools, realtime v3 over WebRTC),
and a PlanQuota that reads account/rateLimits/read. Each app-server is
initialized and checked against the pinned Codex versions first; an
untested Codex is not used.

serve tries Codex first and falls back to GPT-Live. New settings:
voice.codexModel, codexReasoningEffort, minPlanQuotaPercent and
acceptedCodexVersions. The systemd unit gets the installer's PATH, so
the service finds codex.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thomaseude

Copy link
Copy Markdown
Owner Author

Draft of the spec #15 update for #56 (the agent was not allowed to edit the issue). Diff against the current body:

@@ -11,7 +11,7 @@
 Two parts, installed by the user:
 
 - **An iOS app, "T3 Voice".** It starts a voice conversation behind Face ID, from the Action Button, Siri, Control Center, the app, or a notification. The conversation keeps going with the screen locked. The app carries only audio plus a small control channel. It has no access to T3 and holds no API key.
-- **A companion service, `t3-voice`.** It runs next to the T3 Code server, which can be any T3 server, not just Thomas's. It holds the OpenAI key and opens the voice session with OpenAI GPT-Live. It acts on T3 through the tools the voice model calls, tracks the tasks the user follows, speaks announcements during the conversation, and sends push notifications outside it.
+- **A companion service, `t3-voice`.** It runs next to the T3 Code server, which can be any T3 server, not just Thomas's. It opens the voice session with Codex on the user's ChatGPT plan, or with OpenAI GPT-Live and the OpenAI key (#56). It acts on T3 through the tools the voice model calls, tracks the tasks the user follows, speaks announcements during the conversation, and sends push notifications outside it.
 
 In a conversation, Thomas can ask what is running or what finished today, start a task ("Lance Claude sur Joombo pour corriger les tests des Reviews"), send a follow-up, follow or stop following a thread, get details, answer an agent's question, accept or decline a permission request once, and interrupt a task after confirming. When a followed task finishes, fails or needs him, the assistant says so out loud. If no conversation is open, a notification arrives instead, with actions for permissions and questions.
 
@@ -136,7 +136,7 @@
 ## Implementation Decisions
 
 ### Overall architecture
-- **Three parties.** The iPhone talks only to the companion (HTTPS control) and to OpenAI (WebRTC audio). The companion talks to T3 on loopback (`127.0.0.1:3773`) and to OpenAI (session setup and the server-side control channel). The iPhone never talks to T3.
+- **Three parties.** The iPhone talks only to the companion (HTTPS control) and to OpenAI (WebRTC audio). The companion talks to T3 on loopback (`127.0.0.1:3773`) and to OpenAI (session setup and the server-side control channel). On the Codex engine, a `codex app-server` that the companion starts sets up the session with `chatgpt.com/backend-api/codex/realtime/calls`. The iPhone never talks to T3.
 - **Languages.**
   - The **companion is TypeScript on Node** (decided with Thomas over Ruby/Rails). T3 users already have Node, and the T3 protocol and awareness rule are TypeScript.
   - Keep dependencies few: an HTTP server, a WebSocket client, a SQLite driver and an APNs client. No heavy framework.
@@ -168,7 +168,7 @@
    - Failures carry `failure.class`, message, `retryable` and `resetAt`.
 4. **Task registry (SQLite).**
    - **Followed tasks:** thread id, project, spoken name, origin (voice-started / followed), last announced state + event key, stream cursor.
-   - **Other tables:** paired devices (hashed tokens, push tokens, Live Activity push tokens, revoked flag); usage records (session id, engine, minutes, estimated cost); settings overrides.
+   - **Other tables:** paired devices (hashed tokens, push tokens, Live Activity push tokens, revoked flag); usage records (session id, engine, billing `usd` or `plan_quota`, minutes, estimated cost); settings overrides.
    - **The registry is `~/.config/t3voice/tasks.sqlite`** (mode 600), opened with Node's built-in `node:sqlite` driver. It adds no dependency (decided by Thomas in #20).
    - **Paired devices stay out of the registry until #37.** They live in `~/.config/t3voice/devices.json` (mode 600): id, name, SHA-256 of the token, dates. Only `serve` writes it. `t3-voice devices revoke` writes one file per revoked device, `revoked/<device id>.json` (mode 600), instead, so the two processes never overwrite each other (decided by Thomas in #18). Ticket #37 moves them into the registry (decided by Thomas in #20).
    - Survives restarts. T3 remains the only source of truth for status.
@@ -187,6 +187,14 @@
      - The companion's control channel receives `session.input_transcript.delta` and `session.output_transcript.delta`: announcements wait for a 2 s gap with no transcript (checked on the iPhone in #22).
      - Model `gpt-live-1`, voice `brise`.
    - **Plan B, a separate ticket after the core:** a `gpt-realtime-2.1` adapter with WebRTC + sideband `?call_id=`, function calls, `conversation.item.create` + `response.create`, and **semantic VAD only**. The engine becomes a companion setting applied at the next session.
+   - **Each engine says who pays for its minutes** (`billing`): `usd` (the OpenAI API key) or `plan_quota` (a ChatGPT plan, no money).
+   - **Codex adapter, `codex-live` (#56, from the spike in PR #55).** Voice on the ChatGPT plan of the user the companion runs as (`codex login`). Its minutes draw from the plan's quota, not from money.
+     - The companion starts one `codex app-server` per session, as its own user, in an empty temporary folder.
+     - It starts an ephemeral Codex thread: `read-only` sandbox, approval policy `never`, `features.shell_tool = false`, the companion's tools as `dynamicTools`. Model `gpt-6.1-terra`, reasoning effort `low` (settings `codexModel`, `codexReasoningEffort`).
+     - It starts realtime `v3` over WebRTC with the iPhone's offer, `clientManagedHandoffs: true`, and the companion's instructions as `prompt`. The voice model cannot call the companion's tools: it hands each request to the Codex thread. The thread calls the tools (`item/tool/call`). When the thread's turn completes, the companion speaks its final answer with `thread/realtime/appendSpeech`.
+     - The adapter declines every approval request. A tool action takes 4 to 8 s. The Codex voice has no `brise`: it uses Codex's default voice.
+     - **Pinned Codex versions, fail closed.** The `thread/realtime/*` API is experimental: it changed between Codex 0.156 and 0.165. Each time the adapter starts an app-server, it reads the Codex version from the `userAgent` of `initialize`. If the version is not in the pin list (`0.163.0`), the adapter does not use Codex. No version range is accepted. `voice.acceptedCodexVersions` in `config.json` replaces the list on one machine. To support a new version: add it to the pin, then open a session from the iPhone. Keep the version only if the session opens, the assistant speaks, and a tool action with a spoken "oui" runs. No automated test uses the real Codex, because a session draws from the plan's quota.
+   - **`PlanQuota` port**, implemented by the Codex adapter with `account/rateLimits/read` on a short-lived app-server. It returns the percent left in the 5-hour window and in the week, and whether a limit is reached.
 7. **Tools exposed to the voice model.** English names and descriptions; the assistant speaks French.
 
    | Tool | Confirmation level |
@@ -244,7 +252,16 @@
     - the 5-min interruption cap;
     - rollover before the engine cap, during a silence, with a summary seed;
     - reconnect with a seed, giving up after 3 attempts in about 1 min;
-    - usage recording, and the daily budget check before opening a session (default budget $10/day, configurable).
+    - the engine choice when a session opens (#56). A running session stays on its engine: a change of engine needs a new WebRTC connection from the iPhone. The rule takes the lower of the two limits of the plan's quota:
+
+      | What the companion finds | Engine |
+      |---|---|
+      | 20 % or more of the quota left (setting `minPlanQuotaPercent`) | `codex-live` |
+      | Less than 20 % left | GPT-Live with the API key |
+      | Quota unreadable, limit reached, Codex version not pinned, no `codex` binary, or the app-server fails to start or to open the session | GPT-Live with the API key |
+
+      Without an OpenAI key, the GPT-Live rows answer `503 voice_unavailable`. The 20 % leaves quota to the coding agents, which share it with voice (decided by Thomas in #56);
+    - usage recording, and the daily budget check before opening a session (default budget $10/day, configurable). The daily dollar budget counts API minutes only. The usage records count Codex minutes apart, as `plan_quota` minutes at no cost. When the budget is reached, new sessions open on Codex only, and a session on Codex never stops for the budget (decided by Thomas in #56).
 11. **`PushSender` port + ntfy adapter (MVP), APNs adapter later.**
     - **Why ntfy:** the MVP runs on a free Apple team, which can't use APNs. ntfy (open source) gives push without the paid program:
       - a **self-hosted ntfy server** on the VM, published on the Cloudflare Tunnel with ntfy authentication (user + access token, private topic);
@@ -291,9 +308,10 @@
 15. **Configuration and secrets.**
     - Config and secrets live under `~/.config/t3voice/`, mode 600.
     - Secrets: OpenAI key (already in `openai.env`), T3 token, ntfy access token (later the APNs key).
-    - Settings: notification channel (`ntfy` | `apns`), idle durations, engine, voice, daily budget, summary model, pinned T3 version, and `server.publicUrl`, the `https://` address the app reaches the companion at (#18).
+    - Settings: notification channel (`ntfy` | `apns`), idle durations, engine, voice, daily budget, summary model, pinned T3 version, the Codex thread's model and reasoning effort, the share of the plan's quota voice leaves to the agents (`minPlanQuotaPercent`, default 20), pinned Codex versions, and `server.publicUrl`, the `https://` address the app reaches the companion at (#18).
     - Secrets are never logged.
 16. **Deployment.** The companion is an npm package run as a systemd user service next to T3. It pins an exact list of T3 server versions: each one passed the seam 3 integration tests (protocol 2). No version range is accepted. The pin also lists the capability flags the companion depends on: none for now, and a flag is added when a feature starts to depend on it. Its startup check fails closed. To support a new T3 version: add it to the pin, run `T3_VERSION=<version> npm run test:integration`, and keep it only if the tests pass (decided by Thomas in PR #29).
+    - **Server requirements for the Codex engine (#56):** the `codex` binary on the service's PATH (the systemd unit gets the installer's PATH), and a ChatGPT login with `codex login`, as the user the service runs as. Without them, sessions use GPT-Live.
 
 ### Token lifetimes (default chosen; Thomas can override)
 - **T3 token (companion → T3):** T3's paired token lasts 30 days and has no refresh grant. The companion pushes a reminder 3 days before expiry, and `t3-voice t3-repair` renews it.
@@ -346,7 +364,8 @@
 - **What a good test is:** it drives the system through a public seam and asserts on observable behaviour: what is sent to T3, what is spoken, what is pushed, what the HTTP API returns, and which state the iOS session reaches. It never asserts on internal structure. Time is controlled through an injectable clock, never real sleeps.
 - **Seam 1, the main one: companion core through its ports.** The core is tested end to end with in-memory fakes:
   - a fake `T3Backend` that emits scripted shell events and records commands;
-  - a fake `VoiceEngine` that injects tool calls and speech activity and records `speak` calls;
+  - a fake `VoiceEngine` that injects tool calls and speech activity and records `speak` calls (one per engine: API and plan);
+  - a fake `PlanQuota` that returns a set reading or fails;
   - a fake `PushSender` (contract shared by the ntfy and APNs adapters);
   - a fake clock.
 
@@ -361,6 +380,7 @@
   - reconnect give-up;
   - expired requests;
   - the daily budget;
+  - the engine choice by the plan's quota, and the fall back to the API engine;
   - fail-closed on protocol mismatch.
 - **Seam 2: the companion HTTP API.** Real HTTP requests against the server built on the same core and fakes. Covers the pairing window (closed by default, single-use codes, expiry), token checks on every route, revocation, rate limiting, the session-open contract, and notification action routes (action tokens: single use, request-scoped, decline only).
 - **Seam 3: the `T3Backend` WebSocket adapter.** Integration tests against a real `t3 serve` at the pinned version, with a fake provider if available, otherwise a cheap real agent run marked manual. They detect protocol drift when T3 is upgraded.

@thomaseude

thomaseude commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner Author

Code review · 55c54c4 since origin/main · pass 1

Axis 🆕 To do ❓ Your call 🔧 To confirm Done Importance (to do)
🐛 Bugs – – 3 – –
📋 Spec – – 1 – –
📏 Standards – – 3 1 –
🔀 Other provider – – 3 – –

🎯 Critical to do: none

🐛 Bugs

  • B1 🐛 · The companion crashes when Codex refuses or drops a voice session while it opens
    🔧 Fixed, to confirm
    🔴 1 · Critical
    📍 companion/src/adapters/codex-live/codexLiveEngine.ts:130
    🧪 Scenario
    1. A session opens on Codex. start() creates the sdp promise; nothing handles it until thread/realtime/start answers.
    2. Codex answers thread/realtime/start with an error. openSession calls rpc.close(), which kills the child.
    3. The child exits: end("failed") calls rejectSdp on the unhandled promise.
    4. Node's default unhandled-rejection mode stops the companion. The same happens when the app-server dies during the request, when thread/realtime/error comes before the reply, or when the 15 s timer fires while the request waits.
      💡 Idea: attach a no-op handler to sdp as soon as it is created, and test it with a fake whose close() fires the exit listeners like the real child.
      ↳ The realtime request and the SDP answer are awaited together with Promise.all, inside one 15 s withTimeout, so neither rejection is left unhandled; the fake now exits on close() like the real child, and two tests cover a refused start and an exit during it (84fce74).
  • B2 🐛 · A Codex app-server that stops answering blocks that iPhone, and the stop of serve, forever
    🔧 Fixed, to confirm
    🟡 3 · Minor
    📍 companion/src/adapters/codex-live/codexLiveEngine.ts:60
    🧪 Scenario
    1. initialize answers, then Codex stops answering thread/start or thread/realtime/start (no deadline; the SDP timer only rejects sdp, awaited after the request).
    2. openSession never settles: the device's queue never drains, no fall back to GPT-Live.
    3. closeAll awaits the queues, so serve never stops and the child keeps running. close() awaits thread/realtime/stop with no deadline too.
      💡 Idea: wrap thread/start, thread/realtime/start and thread/realtime/stop in withTimeout.
      👥 Also seen by Codex (X2)
      ↳ thread/start and thread/realtime/stop get a 10 s withTimeout, the realtime start a 15 s one; the app-server is stopped on timeout. Three tests with a Codex that never answers (84fce74).
  • B3 🐛 · A quota status of "unknown" is read as "allowed"
    🔧 Fixed, to confirm
    🟡 3 · Minor
    📍 companion/src/adapters/codex-live/codexPlanQuota.ts:48
    🧪 Scenario
    1. Codex answers ordinaryUsageAllowed: null ("Null means unavailable; clients must not infer recovery from percentages", Codex 0.163 GetAccountRateLimitsResponse).
    2. Only === false sets limitReached, so the percentages decide and the session opens on Codex. Ticket: "Quota unreadable … → GPT-Live".
      💡 Idea: treat ordinaryUsageAllowed !== true as a refusal.
      👥 Also seen by Codex (X1)
      ↳ limitReached is now set unless ordinaryUsageAllowed === true; the real Codex answers true on Thomas's account, checked by hand (84fce74).

📋 Spec

📏 Standards

  • S1 📏 · The quota read uses a timeout named for the start of the app-server
    🔧 Fixed, to confirm
    ⚪ 4 · Suggestion
    📍 companion/src/adapters/codex-live/codexRpc.ts:33
    📏 Rule: baseline smell, Mysterious Name.
    🔍 Observed: START_TIMEOUT_MS is documented as the initialize deadline, but withTimeout always uses it, also for account/rateLimits/read.
    💡 Idea: rename it ANSWER_TIMEOUT_MS (the word t3-websocket/webSocketBackend.ts uses), or pass the deadline in.
    ↳ withTimeout takes its deadline as a parameter; the constant is ANSWER_TIMEOUT_MS, the name t3-websocket uses (84fce74).
  • S2 📏 · One concept has three names and two types: "Codex voice", "plan voice", "plan engine"
    ❎ Dismissed
    ⚪ 4 · Suggestion
    📍 companion/src/adapters/cli/serve.ts:49
    📏 Rule: baseline smells, Duplicated Code and Data Clumps.
    🔍 Observed: CodexVoice { engine, quota } in serve.ts and PlanVoice { engine, quota, minPercentLeft } in the core; serve rebuilds one from the other field by field. Logs say "the plan engine" and "Codex only".
    💡 Idea: one type and one word for the concept.
    ↳ Kept on purpose: the core is vendor-neutral (AGENTS.md: ports and core use companion-owned concepts), so it says "plan engine" and holds the threshold read from config (PlanVoice); the CLI names the adapter main.ts builds (CodexVoice, the factory result without the threshold).
  • S3 📏 · Two fields say "this engine costs nothing", and the core checks both
    🔧 Fixed, to confirm
    ⚪ 4 · Suggestion
    📍 companion/src/core/voiceSessions.ts:670
    📏 Rule: baseline smell, Repeated Switches.
    🔍 Observed: CodexLiveEngine sets billing = "plan_quota" and usdPerMinute = 0; usageOf still checks billing === "usd" ? … : 0. The core switches on billing in three places.
    💡 Idea: keep billing only where the budget and the log need it.
    ↳ usageOf multiplies by usdPerMinute, which is 0 on a plan; billing is only read by the budget and the log line (84fce74).
  • S4 📏 · minPlanQuotaPercent gets its default differently from every other voice setting
    🔧 Fixed, to confirm
    ⚪ 4 · Suggestion
    📍 companion/src/ports/configStore.ts:28
    📏 Rule: baseline smell, Shotgun Surgery.
    🔍 Observed: a separate DEFAULT_MIN_PLAN_QUOTA_PERCENT, applied as a destructuring default in serve.ts, while the others come from the DEFAULT_VOICE / DEFAULT_SESSION_LIMITS spreads.
    💡 Idea: put minPlanQuotaPercent: 20 in DEFAULT_SESSION_LIMITS or DEFAULT_VOICE.
    ↳ minPlanQuotaPercent: 20 moved into DEFAULT_VOICE; the separate constant is gone (84fce74).

🔀 Other provider · Codex (codex-cli 0.163.0)

  • X1 🔀🐛 · Voice can draw on the shared plan when one of its two limits is missing
    🔧 Fixed, to confirm
    🟠 2 · Important
    📍 companion/src/core/engineChoice.ts:9
    🧪 Scenario
    1. Codex omits the weekly window, which its protocol allows, while the 5-hour window says 80 % left.
    2. The core drops the missing limit and opens on Codex from the other one. Ticket: "the lower of the two limits"; "Quota unreadable … → GPT-Live".
      💡 Idea: refuse the plan unless both windows give a percent.
      ↳ planQuotaRefusal refuses the plan when either limit is missing: "the plan does not report both of its limits" (84fce74).
  • X3 🔀📋 · A long answer of the Codex thread leaves the user waiting in silence
    🔧 Fixed, to confirm
    🟠 2 · Important
    📍 companion/src/adapters/codex-live/codexLiveEngine.ts:235
    📜 Ticket: "The thread's final answer is spoken with thread/realtime/appendSpeech when its turn completes."
    🔍 In the code: a final answer over 1,200 characters returns undefined, so nothing is spoken on turn/completed.
    💡 Idea: speak a cut answer with a short spoken hint, instead of nothing.
    ↳ Thomas decided to speak a long answer whole: the 1,200-character limit is gone, with a test on a 1,600-character answer (4139746).
  • X4 🔀📋 · The published spec Spec: MVP hands-free iOS voice companion for T3 Code #15 still says GPT-Live is the only voice engine
    🔧 Fixed, to confirm
    🟠 2 · Important
    📍 issue Spec: MVP hands-free iOS voice companion for T3 Code #15, "A companion service" paragraph
    📜 Ticket: "Spec Spec: MVP hands-free iOS voice companion for T3 Code #15 update: the engines, the quota rule, and the server requirements."
    🔍 In the spec: the update is a draft in this PR's first comment; Spec: MVP hands-free iOS voice companion for T3 Code #15 is unchanged.
    💡 Idea: publish the draft (after P1) before merge.
    ↳ Thomas allowed it: Spec: MVP hands-free iOS voice companion for T3 Code #15 is updated with the engines, the quota rule and the server requirements.

Ticking a box dismisses the card. Unticking it, in the newest comment that shows the card, reopens it.

thomaseude and others added 2 commits October 30, 2026 21:40
- A refused or dropped realtime start no longer leaves the SDP promise
  unhandled: the realtime request and the SDP answer are awaited
  together, within 15 s.
- thread/start and thread/realtime/stop answer within 10 s, or the
  app-server is stopped: a stuck Codex no longer blocks a device or
  the stop of serve.
- The plan is used only when Codex says usage is allowed (null means
  unknown) and reports both limits.
- withTimeout takes its deadline; ANSWER_TIMEOUT_MS names it.
- A plan engine's price is 0: usageOf no longer switches on billing.
- minPlanQuotaPercent defaults through DEFAULT_VOICE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thomas decided in review pass 1 (X3): an answer over 1,200 characters
was dropped, which left the user in silence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thomaseude

thomaseude commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner Author

Code review · 4139746 since origin/main · pass 2

Axis 🆕 To do ❓ Your call 🔧 To confirm Done Importance (to do)
🐛 Bugs – – – 3 –
📋 Spec – – – 1 –
📏 Standards – – 1 4 –
🔀 Other provider – – 1 3 –

🎯 Critical to do: none

🐛 Bugs

Nothing to report.

Done in this pass (3)

📋 Spec

Nothing to report.

Done in this pass (1)

📏 Standards

Done in this pass (3)

🔀 Other provider · Codex (codex-cli 0.163.0)

  • X5 🔀📏 · A refusal from Codex can put the voice prompt in the service log
    🔧 Fixed, to confirm
    🟡 3 · Minor
    📍 companion/src/adapters/codex-live/codexLiveEngine.ts:90
    📏 Rule: AGENTS.md: logs carry no prompts; ports/voiceEngine.ts: a VoiceEngineError message "holds no secret and no audio or text".
    🔍 Observed: since 84fce74, Codex's free-text JSON-RPC error message (appServer.ts:62) goes into the VoiceEngineError, which the core logs; scrubSecrets masks credentials only. An error answering thread/start (developerInstructions) or thread/realtime/start (prompt) could echo prompt text.
    💡 Idea: never copy Codex's error text; log a fixed message instead.
    ↳ appServer.ts rejects a Codex error with its code only (codex answered error -32600, checked by hand with the real Codex 0.163); CodexRpc.request documents that its message holds no text from Codex (b6944c3).
Done in this pass (3)

Ticking a box dismisses the card. Unticking it, in the newest comment that shows the card, reopens it.

- Codex's JSON-RPC error text may quote the request, the voice prompt
  included, and it reached the log: the app-server now rejects with the
  error code only.
- The comment on spoken answers states the rule, not the change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thomaseude

thomaseude commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner Author

Code review · b6944c3 since origin/main · pass 3

Axis 🆕 To do ❓ Your call 🔧 To confirm Done Importance (to do)
🐛 Bugs – – – 3 –
📋 Spec – – 1 1 –
📏 Standards – – – 5 –
🔀 Other provider – – – 4 –

🎯 Critical to do: none

🐛 Bugs

Nothing to report.

📋 Spec

  • P2 📋 · When Codex refuses, the log only gives a number, so the operator cannot tell that codex login is missing
    🔧 Fixed, to confirm
    🟡 3 · Minor
    📍 companion/src/adapters/codex-live/appServer.ts:64
    📜 README: "The log line of each choice gives the reason" and "log in with your ChatGPT account (codex login)".
    🔍 In the code: since b6944c3 a Codex error rejects as codex answered error <code>. An app-server with no login still starts and answers account/rateLimits/read with an error, so the log says Codex cannot read the plan's quota: codex answered error -32600, which does not point to codex login. Without a code, the line would say NaN.
    💡 Idea: keep the code only, and add a fixed hint with no Codex text when the quota read fails: "is codex login done for this user?"
    ↳ When the quota read fails, the error adds "is codex login done for this user?" (no Codex text); an error with no code says "with no code". Checked by hand with the real Codex 0.163 and an empty CODEX_HOME: codex answered error -32600; is \codex login` done for this user?` (f17132d).

📏 Standards

Nothing to report.

Done in this pass (1)

🔀 Other provider · Codex (codex-cli 0.163.0)

Nothing to report.

Done in this pass (1)

Ticking a box dismisses the card. Unticking it, in the newest comment that shows the card, reopens it.

A Codex with no login starts, then refuses the quota read with an error
code only: the log now asks whether `codex login` is done. An error
without a code says so instead of NaN.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thomaseude

thomaseude commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner Author

Code review · f17132d since origin/main · pass 4

Axis 🆕 To do ❓ Your call 🔧 To confirm Done Importance (to do)
🐛 Bugs – – 1 3 –
📋 Spec – – – 2 –
📏 Standards – – 1 5 –
🔀 Other provider – – – 4 –

🎯 Critical to do: none

🐛 Bugs

  • B4 🐛 · A quota read that times out or loses Codex still tells the operator to run codex login
    🔧 Fixed, to confirm
    🟡 3 · Minor
    📍 companion/src/adapters/codex-live/codexPlanQuota.ts:30
    🧪 Scenario
    1. Codex is logged in; account/rateLimits/read gets no answer in 10 s, or the app-server exits during the read.
    2. The .catch sits on the whole withTimeout(...), so the log says "codex did not return the quota in time; is codex login done for this user?".
    3. The operator runs codex login again, but the cause is a slow or crashed Codex.
      💡 Idea: add the hint only to an error Codex answered.
      ↳ A Codex error reply is now a CodexRefusal; the quota read adds the hint only to that error, in one catch. A test checks that a timeout gets no hint; checked by hand with an empty CODEX_HOME (e46d40e).

📋 Spec

Nothing to report.

Done in this pass (1)
  • P2 📋 · When Codex refuses, the log only gives a number, so the operator cannot tell that codex login is missing
    ✅ Fixed
    🟡 3 · Minor
    📍 companion/src/adapters/codex-live/appServer.ts:64
    ↳ The quota read adds the codex login hint; an error with no code says so (f17132d).

📏 Standards

  • S6 📏 · The quota read wraps the same error twice, and the login hint lands on failures that have nothing to do with login
    🔧 Fixed, to confirm
    🟡 3 · Minor
    📍 companion/src/adapters/codex-live/codexPlanQuota.ts:30
    📏 Rule: baseline smell, Duplicated Code; Patch on patch (X5 → P2): one rule settles both — the app-server reports a Codex refusal by its code only, and the quota read adds the hint to that kind of error only.
    🔍 Observed: an inner .catch and the outer catch each repeat error instanceof Error ? error.message : String(error); the inner one also catches timeouts and exits.
    💡 Idea: one catch, with the hint only for a Codex refusal.
    ↳ One catch and one message line in read(); the hint rides on error instanceof CodexRefusal, the one rule for X5 and P2: a Codex error keeps its code only, and only it gets the hint (e46d40e).

🔀 Other provider · Codex (codex-cli 0.163.0)

Nothing to report.

Ticking a box dismisses the card. Unticking it, in the newest comment that shows the card, reopens it.

A Codex error reply is a CodexRefusal, kept by its code only. The quota
read adds the codex login hint to a refusal only, in one catch: a
timeout or a Codex exit no longer points to codex login.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thomaseude

thomaseude commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner Author

Code review · e46d40e since origin/main · pass 5

Axis 🆕 To do ❓ Your call 🔧 To confirm Done Importance (to do)
🐛 Bugs – – – 4 –
📋 Spec – – – 2 –
📏 Standards – – 2 6 –
🔀 Other provider – – – 4 –

🎯 Critical to do: none

🐛 Bugs

Nothing to report.

Done in this pass (1)

📋 Spec

Nothing to report.

📏 Standards

  • S7 📏 · The new error class breaks the naming of every other error class in the companion
    🔧 Fixed, to confirm
    ⚪ 4 · Suggestion
    📍 companion/src/adapters/codex-live/codexRpc.ts:29
    📏 Rule: reuse the word the repo already uses. Every other extends Error class ends in Error, and t3-websocket/rpcConnection.ts:14 names the same concept (a JSON-RPC error reply) RpcError.
    🔍 Observed: export class CodexRefusal extends Error.
    💡 Idea: rename it CodexRpcError.
    ↳ Renamed CodexRpcError (d9709a7).

  • S8 📏 · A quota test still shows a login failure as a plain Error, the kind the new rule treats as not about login
    🔧 Fixed, to confirm
    ⚪ 4 · Suggestion
    📍 companion/test/unit/adapters/codex-live/codexPlanQuota.test.ts:101
    📏 Rule: Patch on patch: e46d40e changed the hint rule and left an older test behind.
    🔍 Observed: rpc.limits = new Error("not logged in"); the real app-server raises a plain Error only when it exits.
    💡 Idea: use a neutral failure, e.g. the app-server exiting.
    ↳ The fixture is now new Error("the codex app-server exited"), the case without the hint (d9709a7).

Done in this pass (1)

🔀 Other provider · Codex (codex-cli 0.163.0)

Nothing to report.

Ticking a box dismisses the card. Unticking it, in the newest comment that shows the card, reopens it.

Rename CodexRefusal to CodexRpcError, like RpcError in the T3 adapter.
A quota test fails with the app-server exiting, the case without the
login hint, instead of a plain "not logged in" error Codex never sends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thomaseude

Copy link
Copy Markdown
Owner Author

Code review · d9709a7 since origin/main · pass 6

Axis 🆕 To do ❓ Your call 🔧 To confirm Done Importance (to do)
🐛 Bugs – – – 4 –
📋 Spec – – – 2 –
📏 Standards – – – 8 –
🔀 Other provider – – – 4 –

🎯 Critical to do: none

🐛 Bugs

Nothing to report.

📋 Spec

Nothing to report.

📏 Standards

Nothing to report.

Done in this pass (2)

🔀 Other provider · Codex (codex-cli 0.163.0)

Nothing to report.

Ticking a box dismisses the card. Unticking it, in the newest comment that shows the card, reopens it.

…ment (#56)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thomaseude
thomaseude marked this pull request as ready for review November 16, 2026 14:11
@thomaseude
thomaseude merged commit 0f2f5dd into main Nov 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex voice engine on the ChatGPT plan, with the API under 20 % of quota

1 participant