Skip to content

feat: add Kiro provider with @ai-sdk/kiro SDK#18408

Open
GyuminJack wants to merge 8 commits intoanomalyco:devfrom
GyuminJack:kiro-provider-base
Open

feat: add Kiro provider with @ai-sdk/kiro SDK#18408
GyuminJack wants to merge 8 commits intoanomalyco:devfrom
GyuminJack:kiro-provider-base

Conversation

@GyuminJack
Copy link

@GyuminJack GyuminJack commented Mar 20, 2026

Issue for this PR

N/A — new feature, no existing issue.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds Kiro as a provider in OpenCode. Kiro uses AWS CodeWhisperer-backed Claude models via Builder ID SSO auth.

Changes:

  • New @ai-sdk/kiro SDK under src/provider/kiro/ (converters, streaming, tokenizer, language model, provider factory)
  • Kiro plugin (src/plugin/kiro.ts) handling Builder ID SSO auth + token refresh
  • 7 models registered in provider database (Opus 4.5, Opus 4.6, Sonnet 4.5, Sonnet 4.5 v2, Sonnet 4.6, Haiku 4.5, Haiku 3.5)
  • Reasoning variants support in transform.ts

Built on top of work from:

Two main gotchas with Kiro's API: context window is ~200K tokens (exceeding it causes rejection), and there's no official docs on the exact request payload format — the opencode-kiro-auth repo was essential for figuring that out.

Thanks to both authors for their work 🙏 This is a baseline implementation — some edge cases may not be fully covered, so feedback is welcome.

How did you verify your code works?

  • bun typecheck passes (only pre-existing branded type warnings)
  • bun test — 1450 pass, 8 skip, 1 fail (pre-existing cowsay package issue, unrelated)
  • Manually tested model selection and chat with Kiro provider locally

Screenshots / recordings

N/A — no UI changes, provider shows up in existing model selection UI.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add Kiro language model SDK with converters, streaming, tokenizer,
provider factory, and model resolver for AWS CodeWhisperer integration.
Add Kiro plugin with Builder ID SSO authentication flow, token refresh,
and register it in the plugin index. Add @anthropic-ai/sdk dependency.
Register Kiro in provider database with models: claude-sonnet-4-5,
claude-opus-4-5, claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5,
claude-sonnet-4, claude-3-7-sonnet. Add @ai-sdk/kiro reasoning variants
to transform.
Add Kiro model ID fallback in agent resolution and extend message-v2
for Kiro provider compatibility.
Add tests for Kiro provider registration, model definitions, tool
pairing, compaction, overflow recovery, and plugin auth flow.
Remove tests that depend on compaction functions (shouldCompact,
fitMessages, truncateModelMessages, aggressive mode) not present in
dev baseline. Fix kiro-provider context limit assertion (210K -> 200K).
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 20, 2026
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential duplicate found:

This PR appears to be an earlier attempt at adding Kiro provider support. The current PR #18408 is likely an updated/improved implementation with the @ai-sdk/kiro SDK, suggesting the previous PR may have been closed or superseded.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 20, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

GyuminJack and others added 2 commits March 21, 2026 00:10
- Use ModelID.make() for all kiro model id fields in provider.ts
- Use ProviderID.kiro for kiro provider id and model providerID fields
- Add kiro to ProviderID well-known list in schema.ts
- Fix agent.ts variant fallback to use ModelID.make()
- Fix kiro-provider.test.ts to use branded types in assertions
- Fix mockPlugin to return async for proper .catch() support
@aiml-gmlee aiml-gmlee mentioned this pull request Mar 20, 2026
3 tasks
@duckida
Copy link

duckida commented Mar 21, 2026

Will it have support for other Kiro logins such as Sign in with Google?

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.

2 participants