Skip to content

Commit 75ec6ed

Browse files
lidge-junwtfsayo
andcommitted
feat(devin): fix the request encoding that made every chat turn fail
The cloud provider could not complete a single turn on any account. A paid account settled what it was not: all 229 catalogue models came back enabled and GetChatMessage failed exactly as it had on the free tier, so entitlement was never the cause. Importing the working reference's zero-dependency builder and sending its request through our own transport returned HTTP 200 and a real stream, which put the fault in our encoder rather than the wire. Diffing the two encoded messages field by field left one difference: in CompletionConfiguration, #2 is the output cap and #3 is the context window, and we had them swapped. A caller asking for 32 output tokens wrote 32 into the context-window field, and Cognition answered with an opaque invalid_argument. Fields #6 and #11 are not part of the message at all. A temperature of exactly 0 is refused with that same opaque error. Deterministic output is the ordinary case for a coding client, so it is clamped to the smallest accepted value rather than silently replaced with the service default. Three transport facts had to hold together, which is why testing them one at a time looked fruitless: the credential is the session token doubled and dash-joined in an Authorization: Basic header while the body keeps one copy, the request envelope is uncompressed, and Metadata #31 carries a 732-character fingerprint whose length the service checks. The metadata identity is its own seven-field shape rather than the desktop client's telemetry set, the request carries the verified tag set, and the short-lived user_jwt is now opt-in because the chat path does not need it. Verified live on a paid account: six combinations, two hosts by three models, all returning PONG with a finish reason and usage. A regression test pins the tag map so the swap cannot return silently. Co-authored-by: Sayo <[email protected]>
1 parent 3573742 commit 75ec6ed

14 files changed

Lines changed: 262 additions & 33 deletions

File tree

‎devlog/_plan/260911_devin_two_providers/003_live_evidence.md‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,70 @@ was reverted; only the wp1 hardening and the MIT notice remain.
101101
Confirming this needs a paid account or a captured working request. Neither is
102102
available in this session, so the cloud provider is not merge-ready and the
103103
adapter's own model gate is what stops a user hitting this blindly.
104+
105+
## The chat path works. What was actually wrong.
106+
107+
A paid account was obtained on 2026-09-12 and the entitlement hypothesis died
108+
immediately: all 229 catalogue models came back enabled, and `GetChatMessage`
109+
failed exactly as it had on the free account. The failure was never about the
110+
plan.
111+
112+
Isolating it took one decisive move. The most actively maintained reference
113+
(`dwgx/WindsurfAPI`) is zero-dependency ESM, so its request builder can simply be
114+
imported. Building a turn with the reference builder and sending it through our
115+
own transport returned **HTTP 200** and a real Connect stream — which proved the
116+
transport, the headers and the credential were all fine, and put the fault in our
117+
request encoder. Diffing the two encoded messages field by field left exactly one
118+
difference: `CompletionConfiguration` (#8).
119+
120+
reference #1=1 #2=8192 #3=128000 #5=double #7=40 #8=double
121+
ours #1=1 #2=64000 #3=32 #5=double #6=double #7=50 #8=double #11=double
122+
123+
**#2 is the output cap and #3 is the context window; we had them swapped.** A
124+
caller asking for 32 output tokens wrote 32 into the context-window field, and
125+
Cognition answered with an opaque `invalid_argument: an internal error occurred`.
126+
That is why every account failed identically and why no amount of probing the
127+
transport helped. The reference's own comments record the same mis-tagging and
128+
the same re-calibration.
129+
130+
A second, independent trap sat behind it: **a temperature of exactly 0 is
131+
refused** with the same opaque error. Deterministic output is the common case for
132+
coding clients, so it is clamped to the smallest accepted value rather than
133+
silently replaced with the service default.
134+
135+
Three transport facts also had to be right together, and testing them one at a
136+
time is why they looked useless earlier:
137+
138+
- the credential is the session token doubled and dash-joined in
139+
`Authorization: Basic`, while the protobuf body keeps a single copy;
140+
- the request envelope is uncompressed;
141+
- `Metadata` #31 carries 732 hex characters, whose length the service checks and
142+
whose value it does not.
143+
144+
The metadata identity is also its own shape — seven fields, the optional
145+
`user_jwt`, and the fingerprint — not the desktop client's fuller telemetry set.
146+
147+
### Verified
148+
149+
Six combinations, two hosts by three models, all returning `PONG` with a finish
150+
reason and usage:
151+
152+
| host | model | result |
153+
|---|---|---|
154+
| `server.codeium.com` | `swe-2-high` | PONG, stop, 476/36 |
155+
| `server.codeium.com` | `claude-sonnet-5-medium` | PONG, stop, 576/5 |
156+
| `server.codeium.com` | `gpt-5-6-sol-medium` | PONG, 394/6 |
157+
| `server.self-serve.windsurf.com` | `swe-2-high` | PONG, stop, 1/36 |
158+
| `server.self-serve.windsurf.com` | `claude-sonnet-5-medium` | PONG, stop, 576/5 |
159+
| `server.self-serve.windsurf.com` | `gpt-5-6-sol-medium` | PONG, 394/6 |
160+
161+
The tag map is now pinned by a regression test that builds a request and asserts
162+
the field layout, so the swap cannot come back silently.
163+
164+
### What this retracts
165+
166+
The earlier conclusion in this document — that entitlement was the leading
167+
explanation and that the request shape had been ruled out — was wrong. The
168+
request shape was the whole problem; the probing that "ruled it out" changed one
169+
variable at a time against a broken `CompletionConfiguration` that no single
170+
variable could rescue.

‎docs-site/src/content/docs/fr/guides/providers.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ ocx logout <provider>
126126
| `kiro` | `kiro` | `https://runtime.us-east-1.kiro.dev` | La connexion initiale importe la session de l'installation locale de `kiro-cli`, déjà authentifiée (sous Unix, installez avec `curl -fsSL https://cli.kiro.dev/install` &#124; `bash`; sous Windows PowerShell, utilisez `irm 'https://cli.kiro.dev/install.ps1'` &#124; `iex`; puis exécutez `kiro-cli login`). **Ajouter un compte** déconnecte `kiro-cli`, lance une nouvelle connexion dans le navigateur qui change le compte utilisé par `kiro-cli`, puis enregistre les métadonnées propres au profil. Les comptes OpenCodex existants sont préservés ; une annulation ou un échec restaure la session `kiro-cli` précédente. |
127127
| `google-antigravity` | `google` | `https://daily-cloudcode-pa.googleapis.com` | Google OAuth avec le protocole Cloud Code Assist. La découverte en direct utilise le point de terminaison CCA authentifié `v1internal:fetchAvailableModels` et publie les modèles d'agent accessibles au compte connecté ; le catalogue maintenu reste la solution de repli. |
128128
| `cursor` | `cursor` | `https://api2.cursor.sh` | Connexion PKCE expérimentale, transport HTTP/2 en direct et découverte de modèles filtrés par compte. |
129-
| `devin` | `devin` | `https://server.codeium.com` | **La conversation n'est pas vérifiée : sur un compte gratuit réellement testé, la connexion et la découverte des modèles fonctionnent, mais chaque `GetChatMessage` renvoie un `invalid_argument` opaque et aucun tour n'aboutit. Les comptes payants n'ont pas été testés. Utilisez `devin-cli` pour un chemin Devin qui termine ses tours.** Passerelle Cognition/Devin non officielle et expérimentale. La connexion ouvre l'authentification Auth0 dans le navigateur, puis échange le jeton via `RegisterUser` contre une clé d'API durable. Les modèles sont découverts par compte avec `GetCascadeModelConfigs` ; le streaming passe uniquement par `runTurn` sur Connect-RPC. Absente du préréglage du tableau de bord par défaut. |
129+
| `devin` | `devin` | `https://server.codeium.com` | Passerelle Cognition/Devin non officielle et expérimentale. La connexion ouvre l'authentification Auth0 dans le navigateur, puis échange le jeton via `RegisterUser` contre une clé d'API durable. Les modèles sont découverts par compte avec `GetCascadeModelConfigs` ; le streaming passe uniquement par `runTurn` sur Connect-RPC. Absente du préréglage du tableau de bord par défaut. |
130130
| `devin-cli` | `devin-cli` | `https://cli.devin.ai` | Pilote la CLI Devin installée localement via l'Agent Client Protocol (`devin acp`, JSON-RPC sur stdio). La CLI détient ses propres identifiants issus de `devin auth login`, donc opencodex ne stocke aucune clé. `OPENCODEX_DEVIN_CLI_BIN` désigne l'exécutable ; pour autoriser la CLI à lire et écrire des fichiers, il faut définir explicitement `OPENCODEX_DEVIN_CLI_ALLOW_TOOLS=1`, le refus étant la valeur par défaut. |
131131
| `github-copilot` | `openai-chat` | `https://api.githubcopilot.com` | Expérimental. Flux d'appareil GitHub et échange `copilot_internal` (client OAuth de VS Code). Nécessite un abonnement Copilot actif ; il ne s'agit pas d'une API tierce officielle. |
132132

‎docs-site/src/content/docs/guides/integrations.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ typed values into quoted strings. This includes values inside arrays and inline
212212
tables. Quoted date strings remain supported; an unquoted date must be preserved
213213
by editing the configuration manually.
214214

215-
**Pi, Kimi Code, gjc, MiniMax Code, Prime Agent and the managed DSH integration only work against a loopback bind.**
215+
**Pi, Kimi Code, gjc, MiniMax Code, Prime Agent, Aside, Raycast, omo and the managed DSH integration only work against a loopback bind.**
216216
The first four have no config field for the `x-opencodex-api-key` header a non-loopback bind
217217
requires. DSH has a generic headers map, but rc.6 does not document that dedicated admission
218218
header as a supported integration contract, so the managed writer fails closed instead of

‎docs-site/src/content/docs/guides/providers.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ ocx logout <provider>
192192
| `google-antigravity` | `google` | `https://daily-cloudcode-pa.googleapis.com` | Google OAuth over the Cloud Code Assist wire. Live discovery uses CCA's authenticated `v1internal:fetchAvailableModels` endpoint and publishes the agent models available to the signed-in account; the maintained catalog remains the fallback. |
193193
| `cursor` | `cursor` | `https://api2.cursor.sh` | Experimental PKCE login, live HTTP/2 transport with an opt-in HTTP/1.1 compatibility path, and account-filtered model discovery. |
194194
| `orcarouter-oauth` | `openai-chat` | `https://api.orcarouter.ai/v1` | Browser consent and key exchange use `https://www.orcarouter.ai` with S256 PKCE. The returned user-owned `sk-orca-…` API key is stored in the existing credential store and reused until revoked. |
195-
| `devin` | `devin` | `https://server.codeium.com` | Experimental unofficial Cognition/Devin bridge. **Chat is unverified: on a measured free account, login and model discovery succeed but every `GetChatMessage` returns an opaque `invalid_argument`, so a turn does not complete. Paid-account chat has not been tested.** Login opens Auth0 browser sign-in, then exchanges the token via Cognition's `RegisterUser` for a long-lived API key; models are discovered per account with `GetCascadeModelConfigs`. Not shown in the dashboard preset by default. Use `devin-cli` for a Devin path that completes turns. |
195+
| `devin` | `devin` | `https://server.codeium.com` | Experimental unofficial Cognition/Devin bridge. Login opens Auth0 browser sign-in, then exchanges the token via Cognition's `RegisterUser` for a long-lived API key; models are discovered per account with `GetCascadeModelConfigs`. Not shown in the dashboard preset by default. Chat, tool calls and usage are verified against a live paid account. |
196196
| `devin-cli` | `devin-cli` | `https://cli.devin.ai` | Drives the locally installed Devin CLI over the Agent Client Protocol (`devin acp`, newline-delimited JSON-RPC on stdio). The CLI holds its own credentials from `devin auth login`, so opencodex stores no key for it. Point `OPENCODEX_DEVIN_CLI_BIN` at a specific build; letting the CLI read and write files requires setting `OPENCODEX_DEVIN_CLI_ALLOW_TOOLS=1` explicitly, because the default is to refuse. |
197197
| `github-copilot` | `openai-chat` | `https://api.githubcopilot.com` | Experimental. GitHub device flow + `copilot_internal` exchange (VS Code OAuth client). Requires an active Copilot subscription; not an official third-party API. |
198198

‎docs-site/src/content/docs/ja/guides/providers.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ ocx logout <provider>
115115
| `kiro` | `kiro` | `https://runtime.us-east-1.kiro.dev` | 初回ログインは、インストール済みでサインインした `kiro-cli` セッションを取り込みます(Unix では `curl -fsSL https://cli.kiro.dev/install` &#124; `bash`、Windows PowerShell では `irm 'https://cli.kiro.dev/install.ps1'` &#124; `iex` でインストールしてから `kiro-cli login` を実行)。**アカウントを追加**は `kiro-cli` をログアウトして新しいブラウザログインを開始し、`kiro-cli` 自体のアカウントを切り替えてアカウント別プロファイルメタデータを保存します。既存の OpenCodex アカウントは保持され、キャンセルまたは失敗時には以前の `kiro-cli` セッションが復元されます。 |
116116
| `google-antigravity` | `google` | `https://daily-cloudcode-pa.googleapis.com` | Google OAuth を Cloud Code Assist wire で使用。ライブ探索は認証済みの CCA `v1internal:fetchAvailableModels` エンドポイントを使用し、ログイン中のアカウントで利用可能な agent モデルのみを公開します。管理されたカタログはフォールバックとして残ります。 |
117117
| `cursor` | `cursor` | `https://api2.cursor.sh` | 実験的 PKCE ログイン、HTTP/2 トランスポート、アカウント別モデル探索をサポート。 |
118-
| `devin` | `devin` | `https://server.codeium.com` | **チャットは未検証です。実際の無料アカウントではログインとモデル取得は成功しますが、`GetChatMessage` が毎回不透明な `invalid_argument` を返しターンが完了しません。有料アカウントは未確認です。ターンが完了する Devin 経路が必要なら `devin-cli` を使ってください。** 実験的な非公式 Cognition/Devin ブリッジ。ログインは Auth0 のブラウザサインインを開き、取得したトークンを `RegisterUser` で長期 API キーに交換します。モデル一覧は `GetCascadeModelConfigs` でアカウントごとに取得し、ストリーミングは Connect-RPC 上の `runTurn` 経路のみを使います。ダッシュボードのプリセットには既定で含まれません。 |
118+
| `devin` | `devin` | `https://server.codeium.com` | 実験的な非公式 Cognition/Devin ブリッジ。ログインは Auth0 のブラウザサインインを開き、取得したトークンを `RegisterUser` で長期 API キーに交換します。モデル一覧は `GetCascadeModelConfigs` でアカウントごとに取得し、ストリーミングは Connect-RPC 上の `runTurn` 経路のみを使います。ダッシュボードのプリセットには既定で含まれません。 |
119119
| `devin-cli` | `devin-cli` | `https://cli.devin.ai` | ローカルにインストールされた Devin CLI を Agent Client Protocol(`devin acp`、stdio 上の JSON-RPC)で駆動します。CLI が `devin auth login` の資格情報を保持するため、opencodex 側はキーを保存しません。実行ファイルは `OPENCODEX_DEVIN_CLI_BIN` で指定でき、CLI にファイル操作を許可するには `OPENCODEX_DEVIN_CLI_ALLOW_TOOLS=1` の明示が必要です(既定は拒否)。 |
120120
| `github-copilot` | `openai-chat` | `https://api.githubcopilot.com` | 実験的。GitHub デバイスフロー + `copilot_internal` 交換(VS Code OAuth クライアント)。有効な Copilot サブスクリプションが必要で、公式のサードパーティ API ではありません。 |
121121

‎docs-site/src/content/docs/ko/guides/providers.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ ocx logout <provider>
113113
| `kiro` | `kiro` | `https://runtime.us-east-1.kiro.dev` | 최초 로그인은 설치하고 로그인한 `kiro-cli` 세션을 가져옵니다(Unix에서는 `curl -fsSL https://cli.kiro.dev/install` &#124; `bash`, Windows PowerShell에서는 `irm 'https://cli.kiro.dev/install.ps1'` &#124; `iex`로 설치한 뒤 `kiro-cli login` 실행). **계정 추가**는 `kiro-cli`에서 로그아웃한 뒤 새 브라우저 로그인을 시작하여 `kiro-cli` 자체의 계정을 전환하고, 계정별 프로필 메타데이터를 저장합니다. 기존 OpenCodex 계정은 유지되며, 취소되거나 실패하면 이전 `kiro-cli` 세션을 복원합니다. |
114114
| `google-antigravity` | `google` | `https://daily-cloudcode-pa.googleapis.com` | Google OAuth를 Cloud Code Assist wire로 사용합니다. 실시간 탐색은 인증된 CCA `v1internal:fetchAvailableModels` 엔드포인트를 사용하며 로그인한 계정에서 사용할 수 있는 agent 모델만 게시합니다. 유지 관리되는 카탈로그는 폴백으로 남습니다. |
115115
| `cursor` | `cursor` | `https://api2.cursor.sh` | 실험적 PKCE 로그인, HTTP/2 전송, 계정별 모델 탐색을 지원합니다. |
116-
| `devin` | `devin` | `https://server.codeium.com` | **대화는 미검증입니다. 실제 무료 계정에서 로그인과 모델 조회는 되지만 `GetChatMessage`가 매번 불투명한 `invalid_argument`를 돌려주어 턴이 끝나지 않습니다. 유료 계정은 확인하지 못했습니다. 턴이 완료되는 Devin 경로가 필요하면 `devin-cli`를 쓰세요.** 실험적인 비공식 Cognition/Devin 브리지. 로그인은 Auth0 브라우저 사인인을 열고, 받은 토큰을 `RegisterUser`로 교환해 장기 API 키를 얻습니다. 모델 목록은 `GetCascadeModelConfigs`로 계정마다 조회하며, 스트리밍은 Connect-RPC 위에서 `runTurn` 경로만 씁니다. 대시보드 프리셋에는 기본으로 없으니 직접 추가하세요. |
116+
| `devin` | `devin` | `https://server.codeium.com` | 실험적인 비공식 Cognition/Devin 브리지. 로그인은 Auth0 브라우저 사인인을 열고, 받은 토큰을 `RegisterUser`로 교환해 장기 API 키를 얻습니다. 모델 목록은 `GetCascadeModelConfigs`로 계정마다 조회하며, 스트리밍은 Connect-RPC 위에서 `runTurn` 경로만 씁니다. 대시보드 프리셋에는 기본으로 없으니 직접 추가하세요. |
117117
| `devin-cli` | `devin-cli` | `https://cli.devin.ai` | 로컬에 설치된 Devin CLI를 Agent Client Protocol(`devin acp`, stdio 위 JSON-RPC)로 구동합니다. CLI가 `devin auth login` 자격증명을 직접 들고 있어 opencodex는 키를 저장하지 않습니다. 실행 파일은 `OPENCODEX_DEVIN_CLI_BIN`으로 지정할 수 있고, CLI가 파일을 읽고 쓰도록 허용하려면 `OPENCODEX_DEVIN_CLI_ALLOW_TOOLS=1`을 명시해야 합니다. 기본값은 거부입니다. |
118118
| `github-copilot` | `openai-chat` | `https://api.githubcopilot.com` | 실험적. GitHub 디바이스 플로우 + `copilot_internal` 교환(VS Code OAuth 클라이언트). 활성 Copilot 구독 필요; 공식 서드파티 API가 아닙니다. |
119119

‎docs-site/src/content/docs/reference/adapters.md‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,6 @@ declarations do not grant approval or change execution policy.
424424

425425
## `devin`
426426

427-
> **Chat is unverified.** On a measured free-tier account (2026-09-12) `RegisterUser` and
428-
> `GetCascadeModelConfigs` succeed, but every `GetChatMessage` returns an opaque
429-
> `invalid_argument` and no turn completes. Client version, request framing, metadata and request
430-
> fields were each ruled out by live probing; entitlement is the leading explanation. Paid-account
431-
> chat has not been tested. Use [`devin-cli`](#devin-cli) for a Devin path that completes turns.
432-
433427
**Targets:** Cognition's `exa.api_server_pb.ApiServerService/GetChatMessage` over HTTPS Connect
434428
streaming at `server.codeium.com`.
435429
**Auth:** Devin/Cognition API key from `provider.apiKey` or the forwarded authorization header.
@@ -447,6 +441,13 @@ Login opens Auth0 browser sign-in, then exchanges the Firebase ID token via
447441
encoding.
448442
- Devin/Cognition API keys do not refresh. Run `ocx login devin` again when the key expires or is
449443
revoked.
444+
- The chat request is calibrated, not guessed. Three things gate it together: the credential is the
445+
session token doubled and dash-joined in an `Authorization: Basic` header while the protobuf body
446+
keeps one copy, the request envelope goes up uncompressed, and `Metadata` #31 carries a
447+
732-character device fingerprint whose length — not value — the service checks. Inside
448+
`CompletionConfiguration`, #2 is the output cap and #3 is the context window; swapping those two
449+
makes every turn fail with an opaque `invalid_argument`. A temperature of exactly 0 is refused, so
450+
it is clamped to the smallest accepted value.
450451
- Experimental unofficial bridge; not shown in the dashboard preset by default. See the
451452
[provider guide](/guides/providers/) for login instructions.
452453

0 commit comments

Comments
 (0)