Repository navigation
feat(companion): Codex voice engine on the ChatGPT plan, API under 20 % of quota (#56) - #57
Conversation
…#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>
|
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. |
Code review ·
|
| 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- A session opens on Codex.
start()creates thesdppromise; nothing handles it untilthread/realtime/startanswers. - Codex answers
thread/realtime/startwith an error.openSessioncallsrpc.close(), which kills the child. - The child exits:
end("failed")callsrejectSdpon the unhandled promise. - Node's default unhandled-rejection mode stops the companion. The same happens when the app-server dies during the request, when
thread/realtime/errorcomes before the reply, or when the 15 s timer fires while the request waits.
💡 Idea: attach a no-op handler tosdpas soon as it is created, and test it with a fake whoseclose()fires the exit listeners like the real child.
↳ The realtime request and the SDP answer are awaited together withPromise.all, inside one 15 swithTimeout, so neither rejection is left unhandled; the fake now exits onclose()like the real child, and two tests cover a refused start and an exit during it (84fce74).
- A session opens on Codex.
- 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
🧪 Scenarioinitializeanswers, then Codex stops answeringthread/startorthread/realtime/start(no deadline; the SDP timer only rejectssdp, awaited after the request).openSessionnever settles: the device's queue never drains, no fall back to GPT-Live.closeAllawaits the queues, soservenever stops and the child keeps running.close()awaitsthread/realtime/stopwith no deadline too.
💡 Idea: wrapthread/start,thread/realtime/startandthread/realtime/stopinwithTimeout.
👥 Also seen by Codex (X2)
↳thread/startandthread/realtime/stopget a 10 swithTimeout, 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- Codex answers
ordinaryUsageAllowed: null("Null means unavailable; clients must not infer recovery from percentages", Codex 0.163GetAccountRateLimitsResponse). - Only
=== falsesetslimitReached, so the percentages decide and the session opens on Codex. Ticket: "Quota unreadable … → GPT-Live".
💡 Idea: treatordinaryUsageAllowed !== trueas a refusal.
👥 Also seen by Codex (X1)
↳limitReachedis now set unlessordinaryUsageAllowed === true; the real Codex answerstrueon Thomas's account, checked by hand (84fce74).
- Codex answers
📋 Spec
- P1 📋 · The draft update of Spec: MVP hands-free iOS voice companion for T3 Code #15 still says the budget stops new sessions, and that a 503 means "no OpenAI key"
🔧 Fixed, to confirm
🟡 3 · Minor
📍 draft of Spec: MVP hands-free iOS voice companion for T3 Code #15 (first comment of this PR): story 85 and thePOST /sessionserrors line
📜 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 code:openSessiontries Codex before the budget check, and opens on Codex without a key. The draft says so further down, but story 85 ("stops new sessions once reached") and "503 voice_unavailable(no OpenAI key)" are left as before.
💡 Idea: rewrite story 85 (the budget stops new API sessions) and the 503 line ("no OpenAI key, and Codex cannot be used") before publishing.
↳ Story 85 now says the budget stops new API sessions only, and the 503 line says "no OpenAI key, and Codex cannot be used"; published in Spec: MVP hands-free iOS voice companion for T3 Code #15.
📏 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_MSis documented as theinitializedeadline, butwithTimeoutalways uses it, also foraccount/rateLimits/read.
💡 Idea: rename itANSWER_TIMEOUT_MS(the wordt3-websocket/webSocketBackend.tsuses), or pass the deadline in.
↳withTimeouttakes its deadline as a parameter; the constant isANSWER_TIMEOUT_MS, the namet3-websocketuses (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 andPlanVoice { 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:CodexLiveEnginesetsbilling = "plan_quota"andusdPerMinute = 0;usageOfstill checksbilling === "usd" ? … : 0. The core switches onbillingin three places.
💡 Idea: keepbillingonly where the budget and the log need it.
↳usageOfmultiplies byusdPerMinute, which is 0 on a plan;billingis only read by the budget and the log line (84fce74). - S4 📏 ·
minPlanQuotaPercentgets 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 separateDEFAULT_MIN_PLAN_QUOTA_PERCENT, applied as a destructuring default in serve.ts, while the others come from theDEFAULT_VOICE/DEFAULT_SESSION_LIMITSspreads.
💡 Idea: putminPlanQuotaPercent: 20inDEFAULT_SESSION_LIMITSorDEFAULT_VOICE.
↳minPlanQuotaPercent: 20moved intoDEFAULT_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- Codex omits the weekly window, which its protocol allows, while the 5-hour window says 80 % left.
- 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.
↳planQuotaRefusalrefuses 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 withthread/realtime/appendSpeechwhen its turn completes."
🔍 In the code: a final answer over 1,200 characters returnsundefined, so nothing is spoken onturn/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.
- 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>
Code review ·
|
| 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)
- B1 🐛 · The companion crashes when Codex refuses or drops a voice session while it opens
✅ Fixed
🔴 1 · Critical
📍companion/src/adapters/codex-live/codexLiveEngine.ts:131
↳start()awaitsPromise.all([realtime, sdp])inside one 15 swithTimeout: both rejections are handled (84fce74). - B2 🐛 · A Codex app-server that stops answering blocks that iPhone, and the stop of serve, forever
✅ Fixed
🟡 3 · Minor
📍companion/src/adapters/codex-live/codexLiveEngine.ts:60
↳thread/startandthread/realtime/stopare bounded at 10 s, the realtime start at 15 s; the app-server is stopped on timeout (84fce74). - B3 🐛 · A quota status of "unknown" is read as "allowed"
✅ Fixed
🟡 3 · Minor
📍companion/src/adapters/codex-live/codexPlanQuota.ts:50
↳limitReachedunlessordinaryUsageAllowed === true(84fce74).
📋 Spec
Nothing to report.
Done in this pass (1)
- P1 📋 · The draft update of Spec: MVP hands-free iOS voice companion for T3 Code #15 still says the budget stops new sessions, and that a 503 means "no OpenAI key"
✅ Fixed
🟡 3 · Minor
📍 issue Spec: MVP hands-free iOS voice companion for T3 Code #15: story 85 and thePOST /sessionserrors line
↳ Both lines rewritten and published in Spec: MVP hands-free iOS voice companion for T3 Code #15.
📏 Standards
- S5 📏 · A comment tells the story of a review decision instead of saying what its line does
🔧 Fixed, to confirm
⚪ 4 · Suggestion
📍companion/src/adapters/codex-live/codexLiveEngine.ts:245
📏 Rule: a comment that explains a past change (the repo's/comment-cleanupremoves these). The repo's "(decided by Thomas in #NN)" tags always sit on a comment that says what the code does.
🔍 Observed:// A long answer is spoken whole too (decided by Thomas in #56).sits aboveif (text === "") return undefined;; "too" only makes sense against the removedMAX_SPOKEN_CHARScheck.
💡 Idea: say the present rule: "Every non-empty answer is spoken, however long (decided by Thomas in Codex voice engine on the ChatGPT plan, with the API under 20 % of quota #56)."
↳ The comment now says the rule: "Every non-empty answer is spoken, however long (decided by Thomas in Codex voice engine on the ChatGPT plan, with the API under 20 % of quota #56)." (b6944c3)
Done in this pass (3)
- S1 📏 · The quota read uses a timeout named for the start of the app-server
✅ Fixed
⚪ 4 · Suggestion
📍companion/src/adapters/codex-live/codexRpc.ts:33
↳withTimeouttakes its deadline;ANSWER_TIMEOUT_MS(84fce74). - S3 📏 · Two fields say "this engine costs nothing", and the core checks both
✅ Fixed
⚪ 4 · Suggestion
📍companion/src/core/voiceSessions.ts:660
↳usageOfmultiplies byusdPerMinute, 0 on a plan (84fce74). - S4 📏 ·
minPlanQuotaPercentgets its default differently from every other voice setting
✅ Fixed
⚪ 4 · Suggestion
📍companion/src/ports/configStore.ts:23
↳ Moved intoDEFAULT_VOICE(84fce74).
🔀 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: aVoiceEngineErrormessage "holds no secret and no audio or text".
🔍 Observed: since 84fce74, Codex's free-text JSON-RPC error message (appServer.ts:62) goes into theVoiceEngineError, which the core logs;scrubSecretsmasks credentials only. An error answeringthread/start(developerInstructions) orthread/realtime/start(prompt) could echo prompt text.
💡 Idea: never copy Codex's error text; log a fixed message instead.
↳appServer.tsrejects a Codex error with its code only (codex answered error -32600, checked by hand with the real Codex 0.163);CodexRpc.requestdocuments that its message holds no text from Codex (b6944c3).
Done in this pass (3)
- X1 🔀🐛 · Voice can draw on the shared plan when one of its two limits is missing
✅ Fixed
🟠 2 · Important
📍companion/src/core/engineChoice.ts:9
↳ Refused unless both limits are reported (84fce74). - X3 🔀📋 · A long answer of the Codex thread leaves the user waiting in silence
✅ Fixed
🟠 2 · Important
📍companion/src/adapters/codex-live/codexLiveEngine.ts:245
↳ Spoken whole, as Thomas decided (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
🟠 2 · Important
📍 issue Spec: MVP hands-free iOS voice companion for T3 Code #15
↳ Spec: MVP hands-free iOS voice companion for T3 Code #15 is updated. Codex's re-check read the local file from before publication;gh issue view 15showscodex-live,minPlanQuotaPercentand "stops new API sessions".
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>
Code review ·
|
| 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 loginis 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 ascodex answered error <code>. An app-server with no login still starts and answersaccount/rateLimits/readwith an error, so the log saysCodex cannot read the plan's quota: codex answered error -32600, which does not point tocodex login. Without acode, the line would sayNaN.
💡 Idea: keep the code only, and add a fixed hint with no Codex text when the quota read fails: "iscodex logindone for this user?"
↳ When the quota read fails, the error adds "iscodex logindone 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 emptyCODEX_HOME:codex answered error -32600; is \codex login` done for this user?` (f17132d).
📏 Standards
Nothing to report.
Done in this pass (1)
- S5 📏 · A comment tells the story of a review decision instead of saying what its line does
✅ Fixed
⚪ 4 · Suggestion
📍companion/src/adapters/codex-live/codexLiveEngine.ts:245
↳ The comment states the rule (b6944c3).
🔀 Other provider · Codex (codex-cli 0.163.0)
Nothing to report.
Done in this pass (1)
- X5 🔀📏 · A refusal from Codex can put the voice prompt in the service log
✅ Fixed
🟡 3 · Minor
📍companion/src/adapters/codex-live/appServer.ts:64
↳ A Codex error keeps its code only (b6944c3).
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>
Code review ·
|
| 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- Codex is logged in;
account/rateLimits/readgets no answer in 10 s, or the app-server exits during the read. - The
.catchsits on the wholewithTimeout(...), so the log says "codex did not return the quota in time; iscodex logindone for this user?". - The operator runs
codex loginagain, 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 aCodexRefusal; the quota read adds the hint only to that error, in onecatch. A test checks that a timeout gets no hint; checked by hand with an emptyCODEX_HOME(e46d40e).
- Codex is logged in;
📋 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 loginis missing
✅ Fixed
🟡 3 · Minor
📍companion/src/adapters/codex-live/appServer.ts:64
↳ The quota read adds thecodex loginhint; 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.catchand the outercatcheach repeaterror instanceof Error ? error.message : String(error); the inner one also catches timeouts and exits.
💡 Idea: onecatch, with the hint only for a Codex refusal.
↳ Onecatchand one message line inread(); the hint rides onerror 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>
Code review ·
|
| 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)
- B4 🐛 · A quota read that times out or loses Codex still tells the operator to run
codex login
✅ Fixed
🟡 3 · Minor
📍companion/src/adapters/codex-live/codexPlanQuota.ts:36
↳ The hint is added to a Codex error reply only; a test checks that a timeout gets none (e46d40e).
📋 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 otherextends Errorclass ends inError, andt3-websocket/rpcConnection.ts:14names the same concept (a JSON-RPC error reply)RpcError.
🔍 Observed:export class CodexRefusal extends Error.
💡 Idea: rename itCodexRpcError.
↳ RenamedCodexRpcError(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 plainErroronly when it exits.
💡 Idea: use a neutral failure, e.g. the app-server exiting.
↳ The fixture is nownew Error("the codex app-server exited"), the case without the hint (d9709a7).
Done in this pass (1)
- S6 📏 · The quota read wraps the same error twice, and the login hint lands on failures that have nothing to do with login
✅ Fixed
🟡 3 · Minor
📍companion/src/adapters/codex-live/codexPlanQuota.ts:33
↳ Onecatch, one message line (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.
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>
Code review ·
|
| 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)
- S7 📏 · The new error class breaks the naming of every other error class in the companion
✅ Fixed
⚪ 4 · Suggestion
📍companion/src/adapters/codex-live/codexRpc.ts:29
↳ RenamedCodexRpcError(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
⚪ 4 · Suggestion
📍companion/test/unit/adapters/codex-live/codexPlanQuota.test.ts:103
↳ The fixture is the app-server exiting (d9709a7).
🔀 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>
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 tochatgpt.com/backend-api/codex/realtime/calls, none toapi.openai.com); withminPlanQuotaPercent: 100the log saidno plan engine for device …: 49 % of the plan's quota is left, under 100 %and the session openedon gpt-live-1.config.jsonis back as it was.sedline of the README for the systemd unit (it now setsPATH, so the service findscodex), thensystemctl --user daemon-reload && systemctl --user restart t3-voice.voice session opened for device … on gpt-live-1-codex, and~/.codex/logs_2.sqliteshows the call tochatgpt.com/backend-api/codex/realtime/calls."minPlanQuotaPercent": 100inconfig.json(restartserve): the next session runs on GPT-Live, and the log gives the reason.What changes
codex-liveadapter (companion/src/adapters/codex-live/), from the spike of PR research: Codex realtime voice on the ChatGPT plan (spike) #55:CodexLiveEngine, aVoiceEngine: onecodex app-serverper session, an ephemeral thread (read-only sandbox, approval policynever, no shell, the companion's tools asdynamicTools), realtimev3over WebRTC withclientManagedHandoffs. The thread's final answer is spoken withthread/realtime/appendSpeech.CodexPlanQuota, aPlanQuota:account/rateLimits/readon a short-lived app-server. It returns the percent left in the 5-hour window and in the week.userAgentofinitializeand refuses a version that is not pinned (DEFAULT_CODEX_VERSIONS,0.163.0).voice.acceptedCodexVersionsreplaces the list. An app-server that does not answer in 10 s is stopped.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.VoiceEngine.billingisusdorplan_quota. Usage records get abillingcolumn (migration 5; older records areusd). 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.503 voice_unavailable.voice.codexModel(gpt-6.1-terra),voice.codexReasoningEffort(low),voice.minPlanQuotaPercent(20),voice.acceptedCodexVersions.Environment=PATH=@PATH@. Before, the service's PATH had no nvm folder, so it could not findcodex.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) andnpm run build.CODEX_HOME(no login): the log readsCodex 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.codex0.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. Withoutcodexon 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