Skip to content

fix(desktop): give goose the OpenAI key under the env name it reads - #3398

Open
filipkujawa wants to merge 1 commit into
block:mainfrom
filipkujawa:fix/goose-openai-credential-alias
Open

fix(desktop): give goose the OpenAI key under the env name it reads#3398
filipkujawa wants to merge 1 commit into
block:mainfrom
filipkujawa:fix/goose-openai-credential-alias

Conversation

@filipkujawa

@filipkujawa filipkujawa commented Jul 28, 2026

Copy link
Copy Markdown

Fixes #3395

Bug: Buzz stores the OpenAI key as OPENAI_COMPAT_API_KEY (buzz-agent's env contract, reused as the one secret field for every runtime); goose's openai provider reads OPENAI_API_KEY.
Nothing translates between them, so a goose agent on provider openai calls the API unauthenticated and 401s every turn while readiness reports it Ready.
Confirmed on a live spawned child: GOOSE_PROVIDER=openai with OPENAI_COMPAT_API_KEY present and OPENAI_API_KEY absent.

Fix: At spawn, export the canonical value under OPENAI_API_KEY too when a goose child's effective provider is openai.
Written after the layered user env, and skipped when the agent already carries a native key, so it never clobbers an explicit value.
Scoped to goose (buzz-agent defines the canonical names; claude and codex use CLI login).

Provider resolution: layered env, then Buzz's structured field, then goose's config.yaml, since a later env layer can override GOOSE_PROVIDER in either direction and a config-file-only provider bypasses the field entirely.

Out of scope: openai-compat (goose has no such provider; needs OPENAI_COMPAT_BASE_URL split into OPENAI_HOST + OPENAI_BASE_PATH).
Accepting a user-typed OPENAI_API_KEY in readiness, which has to land together with the config dialogs or the two disagree.

Testing: fmt, clippy, full Tauri lib suite (1816 passed).
New tests cover the alias (mapping, not clobbering an explicit native key, runtime/provider scoping, blank key) and the provider resolution.

@filipkujawa
filipkujawa requested a review from a team as a code owner July 28, 2026 21:00
@filipkujawa
filipkujawa marked this pull request as draft July 28, 2026 21:07
Buzz stores a user-typed OpenAI key as `OPENAI_COMPAT_API_KEY`, buzz-agent's
canonical name, reused as the one secret field for every runtime. goose's
openai provider reads `OPENAI_API_KEY`, and nothing translated between them,
so a goose agent on provider `openai` called the API unauthenticated and 401'd
every turn while readiness reported it Ready.

Export the canonical value under `OPENAI_API_KEY` at spawn when a goose child's
effective provider is `openai`. Written after the layered user env, and skipped
when the agent already carries a native key, so it never clobbers an explicit
value. The provider is resolved as layered env, then Buzz's structured field,
then goose's `config.yaml`, since a later env layer can override
`GOOSE_PROVIDER` in either direction.

`openai-compat` is not aliased: goose reaches those endpoints through `openai`
plus `OPENAI_HOST`/`OPENAI_BASE_PATH`, which needs `OPENAI_COMPAT_BASE_URL`
split into an origin and a path.

Signed-off-by: Filip Kujawa <fkujawa@squareup.com>
@filipkujawa
filipkujawa force-pushed the fix/goose-openai-credential-alias branch from 2c90404 to 8e90d85 Compare July 28, 2026 21:11
@filipkujawa
filipkujawa marked this pull request as ready for review July 28, 2026 21:13
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.

goose + provider openai: the API key never reaches the agent (401 every turn)

1 participant