Skip to content

fix(ai): pin createProvider TApi for xAI Responses provider - #8578

Closed
c0n419 wants to merge 1 commit into
earendil-works:mainfrom
c0n419:fix/v0.84.3-build-errors
Closed

c0n419 wants to merge 1 commit into
earendil-works:mainfrom
c0n419:fix/v0.84.3-build-errors

Conversation

@c0n419

@c0n419 c0n419 commented Aug 24, 2026

Copy link
Copy Markdown

After #8124 routed the built-in xAI catalog through the OpenAI Responses API, the ai workspace stopped building:

```
src/providers/xai.ts(8,2): error TS2322: Type 'Provider<"openai-completions" | "openai-responses">' is not assignable to type 'Provider<"openai-responses">'.
```

`xaiProvider()` declares its return type as `Provider<"openai-responses">` and passes `api: openAIResponsesApi()`. `createProvider`'s generic widens back to `Api` because the `api` field is a single `ProviderStreams` value rather than a literal-keyed `Partial<Record<TApi, ProviderStreams>>` map, so TS infers `Provider` instead of `Provider<"openai-responses">`.

Pass the literal generic explicitly so the call matches the declared signature.

Repro (on v0.84.3 tag)

```
$ cd packages/ai && npm run build:offline
...
src/providers/xai.ts(8,2): error TS2322: ...
```

Verification

After this patch:

  • `packages/ai` (`npm run build:offline`) and `packages/coding-agent` (`npm run build`) both build clean.
  • `packages/ai/test/xai-responses.test.ts` — 10/10 pass.
  • `packages/coding-agent/test/model-resolver.test.ts` — 48/48 pass.
  • `packages/coding-agent/test/compaction.test.ts` + `agent-session-compaction.test.ts` — 24 passed / 7 skipped (pre-existing skips).
  • `node packages/coding-agent/dist/bundle/cli.js --version` → `0.84.3`.
  • `node packages/coding-agent/dist/bundle/cli.js update` → `pi is already up to date (v0.84.3)`, exit 0.

Diff

```diff
--- a/packages/ai/src/providers/xai.ts
+++ b/packages/ai/src/providers/xai.ts
@@
export function xaiProvider(): Provider<"openai-responses"> {

  •   return createProvider({
    
  •   return createProvider<"openai-responses">({
              id: "xai",
              name: "xAI",
              baseUrl: "https://api.x.ai/v1",
    

The xaiProvider factory narrows the return type to Provider<"openai-responses">,
but createProvider's generic was widened back to Api because api was a
single ProviderStreams value rather than a literal-keyed map. Without
the explicit generic, tsgo rejected the call after xAI models were
routed through the Responses API in #8124, breaking ai package builds.

Pass the literal generic explicitly so createProvider returns
Provider<"openai-responses"> and matches the factory's declared signature.
@github-actions

Copy link
Copy Markdown
Contributor

This PR was auto-closed. Only contributors approved with lgtm can open PRs. Open an issue first and ask a maintainer for approval.

Maintainers review auto-closed issues daily. Issues that do not meet the quality bar in CONTRIBUTING.md will not be reopened or receive a reply.

If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open. The command must be at the start of the reply (optionally after one or more @username mentions) or at the end.

See CONTRIBUTING.md.

@github-actions github-actions Bot closed this Aug 24, 2026
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.

1 participant