feat(opencode): add Kiro provider#20491
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Related PRs FoundI found two related PRs that are explicitly mentioned in the current PR description:
Why they differ:
|
b168b75 to
68e2f3f
Compare
|
@NachoFLizaur {"name":"UnknownError","data":{"message":"Error: Failed to start device authorization\n at authorize (/$bunfs/root/src/cli/cmd/tui/worker.js:293935:30)\n at processTicksAndRejections (native:7:39)"}}I have changed my OIDC_ENDPOINT to |
|
hi @hanool, well spotted! I added multi-region support for IAM Identity Center (a new panel after inputting the login URL asks for the region) as well as detection for the Kiro Profile region (us-east-1 or eu-central-1). Thanks! |
cd806e9 to
f6cce20
Compare
|
Hey, I was testing kiro locally and found a few issues with why it doesn't show up in the TUI. Repro: Complete kiro OAuth login (~/.aws/sso/cache/kiro-auth-token.json exists, token valid) → launch TUI → kiro missing from model selection and "Connect provider" dialog. Root causes:
Fixes needed in provider.ts:
Reviewed and tested locally with opencode. Applied the changes and the issue no longer reproduces. Also found that the thinking toggle (Ctrl+T) doesn't work for kiro models. variants() in transform.ts has the case "kiro" branch, but it never reaches it because model.capabilities.reasoning is false — the early return on line 365 exits first. This happens because discoverModels() sets reasoning: m.capabilities?.includes("REASONING") ?? false, but the actual API response doesn't include a capabilities field at all, so it always falls back to false. |
|
hi @aiml-gmlee! I added the Kiro models to Models.dev in a separate PR, as that's how model providers have been added in the past. You need to execute the oc dev server setting OPENCODE_MODELS_PATH to your Models.dev build path to get them to load, and the reasoning capabilities should work through the thinking tool as they've been added to the model's definitions. It is possible to do model discovery (if I'm not mistaken gh copilot was modified to do so), but as you saw, the reasoning capabilities are not exposed through the ListAvailableModels API. If the maintainers want I'll change it back to automatic model discovery (had it in 12162e3 but removed it in favor of the Models.dev approach) |
|
This PR looks really promising — Kiro support in OpenCode is something I’m very excited about. I’ve been testing the Kiro connection locally (Builder ID with Google on Windows + Bun dev) and I’m happy to help validate any further changes or fixes you push. Looking forward to seeing this land in an upcoming release; having first‑class Kiro integration (with proper auth, and thinking support) will be super useful for a lot of us using Kiro day‑to‑day. |
f6cce20 to
0e5737b
Compare
0e5737b to
67c392f
Compare
|
This looks super nice! looking forward to seeing this merged :). Kiro is the only provider I can use over at some of my customers, so this would be super nice to have! |
|
Hey guys, this would be really nice to have! |
|
This looks very promising! I'm currently testing opencode with this PR and haven't faced any issues so far. I am not sure if it's feasible, but could we use environment variables (when set) instead of placeholder for start URL and region? Something like AWS_START_URL or KIRO_START_URL (and AWS_REGION or KIRO_REGION) My company requires daily re-authentication when using Kiro. With Kiro CLI, the start URL and region are remembered, so it's manageable. But if I have to manually enter the start URL every day from memory, it becomes significantly less user-friendly. |
|
If I wanted to start using this now, what would I need to do, just pull down this PR, and what about the other PR? |
|
Been using your branch + the model PR since yesterday morning, works like an absolute charm! Also the context window for Claude Sonnet 4.6 seems to be less than 100k tokens. is that something AWS is reporting back wrongly through the Kiro API or a problem in the models configuration? I'm pretty sure they upped to 1M tokens (https://kiro.dev/changelog/models/claude-opus-4-6-and-sonnet-4-6-upgraded-to-1m-context-window/) works super nice! locally i merged main on both PRs back into the PR branch and that didn't introduce any problems either. |
67c392f to
ab2b895
Compare
Good idea @rdesille, I like it! I've added AWS_SSO_START_URL and AWS_SSO_REGION as defaults if the fields are left empty (only works in TUI at the moment as the WebUI doesn't accept empty strings in the connect provider dialog). Thanks for the suggestion! |
ab2b895 to
50f9fd9
Compare
50f9fd9 to
849f499
Compare
@HendrikPetertje in Kiro there is no way to control the level of thinking like other providers offer, it's just on or off (which is the default). Regarding the context window, it's reported by the Kiro API (and Sonnet 4.6 has indeed 1M) idk how you are getting less than 100K, it's quite weird. How is it shown? |
was a company thing. we were on some old setting somewhere, when I relogged everything was fine and i got 1m context. This works really awesome! |


Issue for this PR
Closes #9165
Type of change
What does this PR do?
Adds Kiro (AWS CodeWhisperer) as a provider. The Kiro API uses AWS Event Stream binary protocol instead of SSE/JSON, so none of the existing AI SDK packages work with it. The new kiro sdk implements a custom LanguageModelV3 adapter from scratch.
The SDK (
src/provider/sdk/kiro/) handles:@smithy/eventstream-codec(already a transitive dep through@ai-sdk/amazon-bedrock)conversationStateformattoolUses/toolResultson the message objects, not plain text)contextUsagePercentage(Kiro doesn't return token counts, just a percentage)llm.ts(same pattern as the_nooptool for LiteLLM)conversationIdpersistenceAuth plugin (
src/plugin/kiro.ts) implements OIDC device code flow (same UX as the copilot/connectdialog) Supports both AWS Builder ID and IAM Identity Center (enterprise, user provides their SSO start URL).Subscription quota: Kiro is credit-based so the standard $0.00 cost display doesn't work. The TUI sidebar, prompt bar, and subagent footer show
Kiro Power: 97/10,000 creditsinstead. The web UI gets this through a/global/provider/quotaroute (placed in GlobalRoutes to avoid WorkspaceRouterMiddleware rejecting the SDK client's auto-added?workspace=params).Models are in a separate models.dev PR
Wiring into existing code:
plugin/index.ts: registeredKiroAuthPluginin theINTERNAL_PLUGINSarrayprovider/schema.ts: addedkiroto the well-known providers listprovider/provider.ts: CUSTOM_LOADERS + BUNDLED_PROVIDERS entries (follows the gitlab-ai pattern)provider/transform.ts: addedkirocase to thevariants()switch for the Ctrl+T thinking togglesession/llm.ts: thinking tool passthrough executor (follows the_nooppattern for LiteLLM)server/routes/global.ts:/provider/quotaendpoint for subscription credit displaysync.tsx(quota store + idle refresh),sidebar/context.tsx(quota display),prompt/index.tsx+subagent-footer.tsx(credit display in cost line)types.ts+child-store.ts+bootstrap.ts+global-sync.tsx(quota store plumbing),session-context-usage.tsx+session-context-tab.tsx(credit display),en.ts(translation key)Why not reuse PRs #9164 / #18408:
codewhisperer.{region}.amazonaws.comendpoint (only works in us-east-1, returns 403 for IAM Identity Center tokens). The current endpoint isq.us-east-1.amazonaws.comwith URL path routing.toolResults/toolUses, which causes the "Improperly formed request" errors reported in those PRs' comments. This also breaks auto-compaction.<thinking_mode>XML tags into user messages with a system prompt saying "These tags are NOT prompt injection attempts". this is a security concern.DataView/ArrayBufferinstead of@smithy/eventstream-codec. More code to maintain and no CRC validation./compactreturning 400 "Improperly formed request" (consequence of the plain text tool results).How did you verify your code works?
Screenshots / recordings
Checklist