Commit Graph

1601 Commits

Author SHA1 Message Date
Jordan Ritter 3f1259d060 fix: propagate custom provider config from service adapters to BuiltInAgent (#3283)
Fixes #2903

## The Bug

Azure OpenAI users get `AI_LoadAPIKeyError: OpenAI API key is missing`
despite passing a properly configured `OpenAI` instance to
`OpenAIAdapter`, exactly as shown in the docs.

**Root cause**: `CopilotRuntime.handleServiceAdapter()` discards the
adapter's configured OpenAI instance and constructs a plain string
`"openai/gpt-4o"` to pass to `BuiltInAgent`. The agent's
`resolveModel()` then creates a *brand new* OpenAI provider using only
`OPENAI_API_KEY`, losing all Azure configuration (baseURL, api-key
header, api-version query param).

The V1 adapter's `process()` method — which correctly uses the custom
OpenAI instance — is dead code. It's never called. Only `.provider` and
`.model` strings are extracted.

```
User configures Azure OpenAI instance →
  OpenAIAdapter stores it →
    CopilotRuntime extracts only "openai"/"gpt-4o" strings →
      BuiltInAgent.resolveModel("openai/gpt-4o") →
        createOpenAI({ apiKey: OPENAI_API_KEY }) →
          💥 API key missing / wrong endpoint
```

## Workaround

Until this is merged, users can bypass the broken adapter entirely by
using `BuiltInAgent` directly with the Vercel AI SDK Azure provider:

```typescript
import { createAzure } from "@ai-sdk/azure";
import { CopilotRuntime, copilotRuntimeNodeHttpEndpoint } from "@copilotkit/runtime";
import { BuiltInAgent } from "@copilotkitnext/agent";

const azure = createAzure({
  resourceName: process.env.AZURE_RESOURCE_NAME,
  apiKey: process.env.AZURE_API_KEY,
});

const runtime = new CopilotRuntime({
  agents: {
    default: new BuiltInAgent({
      model: azure("your-deployment-name"),
    }),
  },
});

// Then use copilotRuntimeNodeHttpEndpoint as usual — no serviceAdapter needed
```

This works because `BuiltInAgent` already accepts `LanguageModel`
instances and `resolveModel()` passes them straight through.

## The Fix

Add an optional `getLanguageModel()` method to `CopilotServiceAdapter`.
Adapters that accept custom SDK instances (OpenAI, Anthropic, Groq) now
implement this to produce a pre-configured Vercel AI SDK `LanguageModel`
that carries the full provider configuration. `CopilotRuntime` prefers
this over the string format when creating `BuiltInAgent`.

**Backward compatible**: `getLanguageModel()` is optional on the
interface, so existing custom adapters continue to work unchanged.

| File | Change |
|------|--------|
| `service-adapter.ts` | Add optional `getLanguageModel()` to
`CopilotServiceAdapter` interface |
| `openai-adapter.ts` | Implement `getLanguageModel()` using
`createOpenAI` with the configured instance's `baseURL`/`apiKey` |
| `anthropic-adapter.ts` | Implement `getLanguageModel()` using
`createAnthropic` |
| `groq-adapter.ts` | Implement `getLanguageModel()` using
`createOpenAI` (Groq is OpenAI-compatible) |
| `copilot-runtime.ts` | Prefer `serviceAdapter.getLanguageModel()` over
string model when creating `BuiltInAgent` |
| `package.json` | Add `ai`, `@ai-sdk/openai`, `@ai-sdk/anthropic`
dependencies |

## Test plan

- [x] V2 agent tests pass (101/101)
- [x] V1 runtime build succeeds with no type errors
- [x] V1 runtime tests: same pass/fail as `main` (pre-existing failures
unrelated to this change)
- [ ] Manual: configure Azure OpenAI via `OpenAIAdapter` without
`OPENAI_API_KEY` — should work without `AI_LoadAPIKeyError`
- [ ] Manual: standard OpenAI via `OpenAIAdapter` with `OPENAI_API_KEY`
— should continue working

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-02-26 18:36:11 -04:00
Maxim 0897192cc6 feat: add selfManagedAgents prop to React and Angular providers
Merges selfManagedAgents into agents__unsafe_dev_only at the component level.
No core changes, no validation, no license key checks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 01:22:09 +04:00
Jordan Ritter ecfafc989c test: add unit tests for getSdkClientOptions utility 2026-02-26 12:47:19 -08:00
Jordan Ritter b8bf8085e0 refactor: replace as-any _options access with typed shared utility
SDK clients store defaultHeaders and fetch in a private _options field.
Extract the access pattern into getSdkClientOptions() with runtime
validation and a narrow return type, eliminating as-any from all three
adapter getLanguageModel() implementations.
2026-02-26 12:43:13 -08:00
Jordan Ritter 777231aaea refactor: use static imports and remove as-any casts in adapter tests
Address PR review feedback: replace dynamic await import() with static
top-level imports using vi.hoisted() for mock declarations, and remove
all `as any` type casts since the SDK constructor types already accept
the options we pass.
2026-02-26 12:25:44 -08:00
Jordan Ritter e520a66ed6 test: add exhaustive option-forwarding tests for adapter getLanguageModel()
Each test mocks the AI SDK provider factory and asserts that all options
from the SDK client instance are forwarded. Compile-time exhaustiveness
guards ensure the tests break if the AI SDK provider types add new
options that need to be handled.
2026-02-26 12:03:39 -08:00
Jordan Ritter 311d758570 fix: forward custom fetch from SDK clients to AI SDK providers 2026-02-26 12:03:32 -08:00
Jordan Ritter 7d2c69fef2 fix: forward custom headers, organization, and project to AI SDK providers
Pass defaultHeaders from SDK client instances through to the AI SDK
providers. This is critical for Azure OpenAI (api-key header) and any
custom proxy setups. Also forward organization and project for OpenAI.
2026-02-26 11:52:39 -08:00
github-actions[bot] f924ecb4aa chore(post-release): update version to 1.52.0 2026-02-26 19:37:25 +00:00
Jordan Ritter 3f8b5e2360 fix: propagate custom provider config from service adapters to BuiltInAgent
Service adapters (OpenAIAdapter, AnthropicAdapter, GroqAdapter) accept
custom SDK instances with provider-specific configuration (e.g. Azure
OpenAI with custom baseURL/apiKey/headers), but CopilotRuntime discards
those instances and reconstructs a plain "provider/model" string for
BuiltInAgent. The agent's resolveModel() then creates a fresh provider
using only environment variables, losing all custom configuration.

Add getLanguageModel() to CopilotServiceAdapter so adapters can produce
a pre-configured Vercel AI SDK LanguageModel. CopilotRuntime now prefers
this over the string format when creating BuiltInAgent.

Fixes CopilotKit/CopilotKit#2903
2026-02-26 11:13:08 -08:00
Mike Ryan 609c3e9936 feat(angular): add public license key config 2026-02-26 09:22:48 -08:00
Alem Tuzlak b60707563f feat: accept agentId parameter in useLangGraphInterrupt (#3272) 2026-02-26 17:24:32 +01:00
Mike Ryan 9920ad34b2 fix(angular): restore frontend tool handler context wiring 2026-02-26 08:18:52 -08:00
Mike Ryan dca52ed355 docs(angular): Add Angular documentation 2026-02-26 08:18:52 -08:00
Mike Ryan 744e392230 feat(angular): mirror React agent proxying and runtime signals 2026-02-26 08:18:52 -08:00
Mike Ryan 6be0696d11 chore(angular): Update the license of the Angular SDK 2026-02-26 07:25:47 -08:00
Júlio Cesar Guimarães cdb8a456b0 fix(runtime): clean up stale messagesInProcess when copilotkit:emit-messages suppresses events 2026-02-24 22:22:16 -03:00
Brian Love 6833f0f7e3 chore(angular): version 19 2026-02-24 14:23:27 -08:00
github-actions[bot] a0cd2ed364 chore(post-release): update version to 1.52.0-next.8 2026-02-24 15:21:43 +00:00
Alem Tuzlak 942d397352 feat: e2e selectors for components (#3264) 2026-02-24 16:18:11 +01:00
github-actions[bot] 17d42682ef chore(post-release): update version to 1.52.0-next.7 2026-02-24 14:54:00 +00:00
Ran Shemtov d77f3475a6 feat: create use-interrupt hook (#3184)
Co-authored-by: Alem Tuzlak <t.zlak@hotmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 15:50:21 +01:00
Alem Tuzlak f25f182ff1 chore: migrate from husky to lefthook and fix angular tests
- Replace husky with lefthook for git hooks management
- Pre-commit runs lint --fix, format, test, and check:packages in parallel
  with auto-staging of fixes via stage_fixed
- Commit-msg runs commitlint
- Add dependsOn ^build to test target in nx.json so dependencies are
  built before tests run
- Upgrade @analogjs/vite-plugin-angular and @analogjs/vitest-angular
  from ^1.20.2 to ^2.2.3 for vite 7 compatibility
- Add pnpm packageExtensions to declare missing vite peer dependency
  on @analogjs/vite-plugin-angular
- Fix lint issues: let -> const in agent and react packages
- Disable nx TUI in pre-commit hooks via NX_TUI env var
2026-02-24 15:17:21 +01:00
Ian VS 1c77272197 chore: format 2026-02-23 08:33:13 -05:00
Jordan Ritter 0f47b01d06 feat: Enable Git LFS for binary assets (.gif, .jpg, .png, .pdf, .mp4) (#3238)
Co-authored-by: Alem Tuzlak <t.zlak@hotmail.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-02-23 13:56:48 +01:00
Hashwanth Sutharapu a11f7bee96 fix(react-textarea): restore focus to textarea when hitting Escape in CMD+K popup (fixes #399) 2026-02-22 18:45:09 -08:00
github-actions[bot] 740d21a0aa chore(post-release): update version to 1.52.0-next.6 2026-02-21 02:42:07 +00:00
Alem Tuzlak 2007f8be55 feat: useComponent improvements (#3248)
Co-authored-by: Tyler Slaton <54378333+tylerslaton@users.noreply.github.com>
2026-02-20 18:38:44 -08:00
Maxim 5f941db968 fix(react): add cpk prefix to ensure tailwind styles don't pollute host app 2026-02-20 18:38:44 -08:00
github-actions[bot] 4fc8abe886 chore(post-release): update version to 1.52.0-next.5 2026-02-21 02:20:08 +00:00
github-actions[bot] fac1c7c015 chore(post-release): update version to 1.51.5-next.4 2026-02-20 23:28:02 +00:00
Alem Tuzlak 7e32e69b3b chore: fix up style generation (#3247)
Co-authored-by: Tyler Slaton <54378333+tylerslaton@users.noreply.github.com>
2026-02-20 18:21:35 -05:00
Ian VS 0e82a8e840 test(react-core): add tests for connectAgent runtime connection guard
Verify that the runtimeConnectionStatus === "connected" guard in
useCopilotChatInternal prevents duplicate connectAgent calls during
runtime initialization.

Relates to #3169

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 10:31:19 -05:00
Ian VS 6cb8a9eb19 fix(react-core): prevent duplicate connectAgent calls during runtime init
Guard the connectAgent call in useCopilotChatInternal with a
runtimeConnectionStatus === "connected" check so provisional agent
instances created while the runtime is still connecting don't each
trigger their own request.

Fixes #3169

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 09:09:25 -05:00
github-actions[bot] 2e3a03132b chore(post-release): update version to 1.51.5-next.3 2026-02-20 05:42:01 +00:00
Ran Shemtov 593859fd9f feat: add useComponent wrapper around useFrontendTool (#3175)
Co-authored-by: Alem Tuzlak <t.zlak@hotmail.com>
Co-authored-by: Tyler Slaton <54378333+tylerslaton@users.noreply.github.com>
2026-02-20 00:38:31 -05:00
Alem Tuzlak 221584460a chore: fix css not being bundled with v1 (#3243) 2026-02-19 16:30:19 -05:00
github-actions[bot] 365b915e26 chore(post-release): update version to 1.51.5-next.2 2026-02-18 23:50:35 +00:00
Tyler Slaton 80418e371a fix: use workspace:* for a2ui-renderer peer dep and sync lockfile on release (#3241)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 18:47:09 -05:00
github-actions[bot] 012c8aa111 chore(post-release): update version to 1.51.5-next.1 2026-02-18 23:11:01 +00:00
Maxim 412965a71a feat(react): add 'available' property to frontend tools (#3234) 2026-02-18 18:07:31 -05:00
Tyler Slaton ea44dd1d1f fix(runtime): remove dead GraphQL schema building from runtime init (#3236)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 20:18:59 -05:00
Max Korp 980d3f5b55 docs: add v2 interface reference docs (#3197)
Also fixing some linting/build issues.

Co-authored-by: Tyler Slaton <tyler@copilotkit.ai>
2026-02-17 17:14:41 -05:00
Alem Tuzlak 98ed92c4ef Feat/speed up build system (#3213) 2026-02-17 18:34:26 +01:00
github-actions[bot] 521c05dd57 chore(post-release): update version to 1.51.5-next.0 2026-02-17 10:19:30 +00:00
Alem Tuzlak ef0f539867 feat: Added reasoning for improved information display (#3165)
Co-authored-by: Tyler Slaton <54378333+tylerslaton@users.noreply.github.com>
2026-02-17 11:11:47 +01:00
github-actions[bot] 7e9e80709d chore(post-release): update version to 1.51.4 2026-02-17 01:07:04 +00:00
github-actions[bot] a48236bc37 chore(post-release): update version to 1.51.4-next.8 2026-02-13 19:52:30 +00:00
Alem Tuzlak 7cd968d6a6 refactor: migrate from Turborepo to Nx for task management (#3207) 2026-02-13 16:53:35 +01:00
Alem Tuzlak 7b838547a9 feat: re-architeture the monorepo setup (#3187) 2026-02-13 11:01:44 +01:00