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! |
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! |
d3a623e to
5fb4c3a
Compare
|
add opus4.7 support?and can u make docs to show how to use it by self build....really need use it in opencode |
Quick Guide: Using this PR locally (without models.dev)Since the models.dev PR hasn't been merged yet, here's how to get Kiro working with just this PR — no need to build models.dev separately. 1. Clone & checkoutgit clone https://github.com/anomalyco/opencode.git
cd opencode
gh pr checkout 20491
bun install2. Configure models manuallySince Kiro isn't on models.dev yet, add models to your global config at {
"provider": {
"kiro": {
"npm": "kiro-ai-provider",
"name": "Kiro",
"models": {
"claude-opus-4.7": {
"name": "Claude Opus 4.7",
"attachment": true, "reasoning": true, "tool_call": true, "temperature": true,
"limit": { "context": 1000000, "output": 64000 }
},
"claude-opus-4.6": {
"name": "Claude Opus 4.6",
"attachment": true, "reasoning": true, "tool_call": true, "temperature": true,
"limit": { "context": 1000000, "output": 64000 }
},
"claude-sonnet-4.6": {
"name": "Claude Sonnet 4.6",
"attachment": true, "reasoning": true, "tool_call": true, "temperature": true,
"limit": { "context": 1000000, "output": 64000 }
},
"auto": {
"name": "Kiro Auto",
"attachment": true, "reasoning": true, "tool_call": true, "temperature": true,
"limit": { "context": 1000000, "output": 64000 }
}
}
}
}
}
3. AuthenticateOption A — API Key (simplest): Create {
"accessToken": "ksk-YOUR_API_KEY_HERE",
"refreshToken": "",
"expiresAt": "2027-01-01T00:00:00.000Z",
"region": "us-east-1"
}Option B — OAuth (Builder ID / IAM Identity Center): bun dev providers login --provider kiro4. Runbun dev # runs in packages/opencode dir
bun dev ~/your-project # runs in a specific directoryUse Ctrl+M to switch to a Kiro model. Note
|
Add formatCost() utility that shows 'X.XX credits' when the provider is kiro and '$X.XX' for all other providers. Applied across all 8 cost display locations: TUI prompt footer, subagent footer, sidebar, web app context usage/tab, CLI stats, share page, and ACP agent. providerID is already available at every display site — no schema or backend changes needed. This commit can be dropped independently if the maintainers prefer a different approach.
69f6a7d to
f11d7b1
Compare
|
Hey Everyone! So last week the Kiro T&C/FAQs were updated to introduce the following: This makes the kiro-ai-provider implementation go directly against them, so I've created a new ai-sdk compatible kiro-acp-ai-provider package that leverages Kiro ACP (via kiro-cli) and updated the PR to use it. The old implementation is still accessible through branch feat/kiro-provider-alt in my fork for reference, but it's not compliant with the current T&C and therefore it cannot be added to opencode. Most of the functionality is kept with the new provider, except:
Token count and context window usage are maintained. The cost now shows the current session's credit usage instead. |
|
hope this will be merge so that i'll cancel my copilot pro+ plan😌 |
does this mean that it doesn't "think" at all, or that its thoughts are just hidden to us? |
|
Pulled the
Tried Kiro in an alto non-open-code client using the ACP adapter in CodeCompanion for Neovim with kiro, and that succeeds: Is there something special i need to do to get Kiro to work in opencode with the latest ACP version of this Nice aside regarding model discovery (don't know how well this will carry over to opencode where this data might be required before a connection to an ACP is made) when a connecting is started with an ACP (kiro-cli acp sub-process is started) you normally
Don't know how useful that info is.. i figure opencode needs to know the models before a connection is made as it lists everything directly. could be nice to use it as a guard though to send a nice message back to the user with a list of the actually supported models (and models details) they have access to... |
The models don't have extended reasoning enabled. You can see it as if you ran the model in the "Default" variant with another provider. As for the way to run it, I recommend to do it as @hanool mentioned:
For the approach that you are taking of adding the models explicitly in the opencode.json, you should use You probably need to do the "Connect Provider" workflow so that the provider recognizes your Kiro token. As the models are registered in Models.dev, once both PRs are merged they should appear automatically. However, you make a good point about verifying the models available to the particular user and only showing them those, I'll look into it! |
|
The problem was that my kiro install wasn't up to date. when the acp adapter sent "--trust-all-tools", it would crash :). Updated it and now Kiro talks back in ACP mode :) 2 things that i noticed:
Did 2 fixes in the patch below:
The limitation is that when you enable or disable tools mid-chat, then kiro won't know about it. so it's not really super duper.. this is probably not the fix you want :s... |
|
Hey @HendrikPetertje, thanks for digging into this and sharing the patch! So regarding the two things you found: MCP tools not loading: I haven't been able to reproduce this on my end. I tested with kiro-cli 2.0.1 and opencode's MCP tools (both built-in ones like read/write/bash and external MCP servers configured in opencode.json) work correctly. Regarding the kiro agent: To give you a little bit more detail, the way the Kiro provider works is that it sets up an IPC adapter and an MCP bridge in between opencode and kiro-cli. The objective of this is to allow the provider to leverage opencode's built in tools and ecosystem of plugins and agents and effectively use Kiro ACP to act as an LLM. The custom agent that you see in .kiro/agents is a kiro custom agent that registers the MCP bridge as its tools, so that it can only "see" and call the tools that opencode exposes. when you configure an MCP in opencode.json and you initiate a conversation, the provider will see it as another more tool and register it in the MCP bridge, allowing Kiro ACP to call it. The approach in your patch adds the MCP servers directly to kiro-cli alongside the bridge, which effectively bypasses it for those tools and has Kiro ACP directly executing them. I decided to have all tools register in the MCP Bridge so that we ensure that it is opencode the one that executes them. Did you have the MCP server issues before or after updating kiro-cli? I just tested it with version 2.0.1 |
|
@NachoFLizaur My guess is that this happens because As a temporary workaround, I was able to make it work by copying cp ~/path/to/opencode-repo/packages/opencode/node_modules/kiro-acp-ai-provider/package.json ~/some/path/parent/node_modules/kiro-acp-ai-provider/.
cp ~/path/to/opencode-repo/packages/opencode/node_modules/kiro-acp-ai-provider/dist/mcp-bridge.js ~/some/path/parent/node_modules/kiro-acp-ai-provider/dist/. |
|
@hanool you are right, this is an issue with the @HendrikPetertje I'll look into the MCPs not working in more detail and see if it's something in my setup that I might have inadvertedly modified. I'll get back to you on this! |
# Conflicts: # bun.lock # packages/opencode/package.json # packages/opencode/src/provider/provider.ts
Includes: concurrent session isolation (per-instance agent configs), bridge extraction for compiled binaries, stderr diagnostics, broader tool call parsing, tools file validation, unique temp naming, and XDG Windows support.
|
I updated the provider to embed the mcp bridge source at build time and extract it to ~/.local/share/ (or whatever XDG path the os where it's running resolves to) at runtime when node_modules isn't available. multiple concurrent sessions should work properly now and the mcp bridge error should be gone now. |
|
@HendrikPetertje, I think I found the cause of the MCP loading issue. There was a race condition where the title generation call would start kiro-cli without MCP tools configured, and when the real message arrived with tools, the already-running instance wouldn't pick them up, so the session used for your interactions had no MCP tools available. I've updated kiro-acp-ai-provider to handle this properly. Please let me know if you continue having issues! |





Issue for this PR
Closes #9165
Type of change
What does this PR do?
Adds Kiro (AWS) as a provider. The Kiro T&C (https://kiro.dev/faq/#with-which-tools-can-i-use-my-kiro-subscription) require third-party tools to go through ACP (Agent Control Protocol). I built a standalone AI SDK compatible package kiro-acp-ai-provider which communicates with Kiro ACP.
Auth plugin (src/plugin/kiro-acp.ts) checks for an existing kiro-cli auth token. If not authenticated it launches kiro-cli login and polls until auth completes. Supports whatever authentication kiro-cli supports (Builder ID, IAM Identity Center, API keys, etc).
Session management (src/provider/provider.ts): custom loader with an intercept() proxy that handles the kiro-cli session lifecycle.
Cost display: Kiro is credit-based so the standard $0.00 cost display doesn't apply. The TUI sidebar, prompt bar, and subagent footer show the current session's credit usage instead. Added support for credit-based providers.
Models are in a separate models.dev PR
Wiring into existing code:
plugin/index.ts: registeredKiroACPAuthPluginin theINTERNAL_PLUGINSarrayprovider/schema.ts: added kiro to the well-known providers listprovider/provider.ts: CUSTOM_LOADERS + BUNDLED_PROVIDERS entries (follows the gitlab-ai pattern)provider.ts: added core package wiring, session lifecycle and proxy logic.transform.ts: added kiro case to the npm package mappingsession.ts: credits extraction from providerMetadatasidebar/context.tsx(credit display),prompt/index.tsx+subagent-footer.tsx(credit display in cost line)session-context-usage.tsx+session-context-tab.tsx(credit display)format-cost.ts: shared credits formatting utilityWhy not reuse PRs #9164 / #18408:
How did you verify your code works?
Screenshots / recordings
Checklist