Skip to content

feat(models): integrate Kimi K3 under opencode-go#123

Merged
samueltuyizere merged 4 commits into
mainfrom
add-kimi-k3
Jul 17, 2026
Merged

feat(models): integrate Kimi K3 under opencode-go#123
samueltuyizere merged 4 commits into
mainfrom
add-kimi-k3

Conversation

@samueltuyizere

@samueltuyizere samueltuyizere commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Integrates the Kimi K3 model as a config-driven alias served through the opencode-go provider — the provider that carries every Kimi model today (k2.5/k2.6/k2.7-code all route through Moonshot upstream via opencode-go).

Specs verified against https://opencode.ai/data/moonshot/kimi-k3:

  • 1M context window
  • 131K max output tokens
  • Modalities: text, image, video
  • Pricing: $3 / 1M input · $15 / 1M output
  • Released July 2026
  • OpenAI Chat Completions endpoint (endpoint classifier confirmed)
  • kimi- prefix handling in the transformer (placeholder reasoning, cache_control) covers K3 automatically — no code-path changes needed
  • Fallback chain: kimi-k3 → kimi-k2.7-code → kimi-k2.6

Changes

  • internal/config/model_registry.go — register kimi-k3 metadata (1M / 131K / vision / tools) (+ test)
  • internal/client/opencode_test.go — endpoint-classification test case
  • configs/config.example.json, cmd/routatic-proxy/main.go, cmd/routatic-proxy/init_provider.go — model entry + fallback chain across all three config sources (consistent vision: true)
  • MODELS.md, docs/models.md, docs/zh/MODELS.md, CLAUDE.md — docs with real specs + pricing
  • Synced catalog.json intentionally left untouched (fetched from remote source; will pick up K3's full catalog entry on next sync)

Testing

  • go build ./...
  • go vet ./...
  • go test ./... ✅ (full suite)
  • Reviewed by phase-reviewer agent; flagged config-source vision inconsistency, fixed.

Notes

  • max_tokens in the config aliases stays at a conservative per-request default (32K); the registry carries the true 131K cap for capacity filtering.
  • K3's 1M context makes it a candidate for the long_context scenario, but routing logic was left unchanged (out of scope).

🤖 Generated with Claude Code

Add the Kimi K3 model as a config-driven alias served through the
opencode-go provider, mirroring existing Kimi model conventions
(256K context, 32K max output, vision, tools, OpenAI Chat Completions
endpoint). The `kimi-` prefix handling in the transformer covers K3
automatically (placeholder reasoning, cache_control), so no code path
changes were needed.

- Register kimi-k3 metadata in model_registry.go
- Add kimi-k3 model + fallback chain (k3 -> k2.7-code -> k2.6) to
  config.example.json and both embedded default templates
- Document across MODELS.md, docs/models.md, docs/zh/MODELS.md, CLAUDE.md
- Add registry + endpoint-classification test coverage

Note: Kimi K3's release/specs are unconfirmed upstream at authoring time;
specs mirror kimi-k2.7-code and cost is marked TBD, to be verified against
Moonshot AI docs. The synced catalog.json is intentionally left untouched
(it is fetched from a remote source).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread cmd/routatic-proxy/init_provider.go Outdated
@kilo-code-bot

kilo-code-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Code Review Roast 🔥

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this incremental commit is actually clean. I need to sit down. I had my flamethrower warmed up and everything.

This round properly resolves the previous review's kimi-k3 triple-copy finding: both getDefaultConfig() (main.go) and getOpenCodeGoConfig() (init_provider.go) now read a single //go:embed templates/default_config.json, and the two 280-line hand-synced JSON blobs are gone. The new TestDefaultAndOpenCodeGoConfigsIdentical + TestExampleConfigSharedModelsMatchDefault turn "these are the same" into a CI-enforced invariant — drift now fails the build instead of shipping silently. That's the kind of fix that respects the original roast rather than hand-waving it away.

The config.example.json superset isn't fully covered by the in-sync test (deliberate — it adds cost_routing/aws_bedrock), but the shared-model assertion guards exactly the vision-flag drift the earlier reviewer caught, so I'm calling the prior finding resolved.

📊 Overall: Like a student who actually studied for the makeup exam — the previous mistake was acknowledged and this follow-up commit fixed it properly.

Files Reviewed (4 files, incremental)
  • cmd/routatic-proxy/init_provider.go - removed hand-synced JSON, now defers to getDefaultConfig() (resolved prior finding)
  • cmd/routatic-proxy/main.go - extracted default config to embedded template
  • cmd/routatic-proxy/init_provider_test.go - new in-sync + shared-model tests (good)
  • cmd/routatic-proxy/templates/default_config.json - new single source of truth
Previous Review Summaries (3 snapshots, latest commit 031ccf7)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 031ccf7)

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this incremental diff is actually clean. I need to sit down. I had my flamethrower warmed up and everything.

The previous review flagged the triple-copied kimi-k3 template block across getOpenCodeGoConfig, getDefaultConfig, and config.example.json (init_provider.go:512). This incremental round answered that feedback properly: both Go template functions now carry explicit SYNC doc comments pointing at the other two sources, and a new TestDefaultAndOpenCodeGoConfigsInSync turns the "these two are the same" claim into a CI-enforced invariant — drift now fails the build instead of shipping silently. That's the kind of fix that respects the original roast rather than hand-waving it away.

📊 Overall: Like a student who actually studied for the makeup exam — the previous mistake was acknowledged and this follow-up commit fixed it properly. The remaining config.example.json isn't covered by the in-sync test, but the SYNC comment covers the paper-trail requirement, so I'm calling it resolved.

Files Reviewed (3 files, incremental)
  • cmd/routatic-proxy/init_provider.go - added SYNC comment (resolved prior finding)
  • cmd/routatic-proxy/main.go - added SYNC comment (resolved prior finding)
  • cmd/routatic-proxy/init_provider_test.go - new in-sync + presence tests (good)

Previous review (commit d3d0d7a)

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this incremental diff is actually clean. I need to sit down. I had my flamethrower warmed up and everything.

Overview

Severity Count
🚨 critical 0
⚠️ warning 0
💡 suggestion 0
🤏 nitpick 0
Issue Details (click to expand)

No new issues found in changed code.


🏆 Best part: The spec fix was thorough — registry metadata, test expectations, and all four doc files (English, Chinese, MODELS.md, CLAUDE.md) are now consistent with the real 1M/131K figures and $3/$15 pricing. That's the kind of complete sync the previous reviewer was begging for.

💀 Worst part: Nothing. I'm actually disappointed. I prepared three different metaphors about triple-copied JSON and I didn't get to use any of them.

📊 Overall: Like a student who actually studied for the makeup exam — the previous mistakes were acknowledged and this follow-up commit fixed them properly.

Files Reviewed (6 files)
  • internal/config/model_registry.go - updated kimi-k3 metadata (1M/131K)
  • internal/config/model_registry_test.go - updated test expectations
  • CLAUDE.md - updated model table
  • MODELS.md - updated pricing/details
  • docs/models.md - updated quick reference table
  • docs/zh/MODELS.md - updated Chinese docs

Previous review (commit ef4ea83)

Verdict: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
🚨 critical 0
⚠️ warning 0
💡 suggestion 1
🤏 nitpick 0
Issue Details (click to expand)
File Line Roast
cmd/routatic-proxy/init_provider.go 508 kimi-k3 model + fallback chain duplicated across 3 hardcoded JSON templates (main.go, init_provider.go, config.example.json) — drift hazard the PR's own history already demonstrated

🏆 Best part: Genuinely clean execution — the registry entry, test coverage (endpoint classification and metadata resolution), and the docs/markdown/CLAUDE.md updates are all consistent and complete across every source. The author even caught and fixed their own vision inconsistency mid-PR. That's discipline.

💀 Worst part: The one finding is the triple-copied kimi-k3 block. Three hand-synced JSON strings is a maintainability landmine waiting for the next Kimi release — the exact defect class the PR already admitted to once.

📊 Overall: Like a tidy desk with three identical sticky notes on it — everything's in the right place, but you only needed one.

Files Reviewed (10 files)
  • internal/config/model_registry.go - registered kimi-k3 metadata
  • internal/config/model_registry_test.go - metadata resolution test
  • internal/client/opencode_test.go - endpoint classification test
  • cmd/routatic-proxy/main.go - default config template
  • cmd/routatic-proxy/init_provider.go - opencode-go config template
  • configs/config.example.json - example config
  • CLAUDE.md - model table
  • MODELS.md - model reference + endpoint tables
  • docs/models.md - model reference
  • docs/zh/MODELS.md - Chinese model reference

Fix these issues in Kilo Cloud


Reviewed by hy3:free · Input: 81.9K · Output: 2.6K · Cached: 275.3K

Review guidance: REVIEW.md from base branch main (truncated)

samueltuyizere and others added 3 commits July 17, 2026 12:19
Verified against https://opencode.ai/data/moonshot/kimi-k3. K3 is a
released flagship, not a K2.7-code clone:
- Context: 1M tokens (was 256K)
- Max output: 131K tokens (was 32K)
- Modalities: text, image, video
- Pricing: $3/1M input, $15/1M output
- Released Jul 2026

Update registry metadata, test expectations, and all docs with the
real figures and pricing (removes the provisional/TBD placeholders).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Addresses reviewer feedback on the triple-duplicated models/fallbacks
blocks (getDefaultConfig, getOpenCodeGoConfig, config.example.json).

- Add SYNC comments on both Go template functions pointing at the other
  two sources, so the next editor knows they are triplets.
- Add TestDefaultAndOpenCodeGoConfigsInSync: the two Go templates claim
  to be identical, so assert their models/fallbacks sections match byte
  for byte — drift now fails CI instead of shipping silently.
- Add TestKimiK3PresentInAllTemplates as a concrete presence check.

A full go:embed single-source refactor was considered but left out of
scope for this model-addition PR (it restructures all provider templates
and the sources are supersets, not interchangeable).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Eliminates the triple-duplicated default config that the reviewer flagged.
The runtime default now lives in one embedded file,
cmd/routatic-proxy/templates/default_config.json:

- main.go: getDefaultConfig() returns the //go:embed'd file
- init_provider.go: getOpenCodeGoConfig() delegates to getDefaultConfig()
  (the default provider IS opencode-go, so they were always meant to match)

This removes ~561 lines of hand-synced JSON string literals and fixes a
latent drift the duplication had already caused: getOpenCodeGoConfig() was
silently missing the model_family_overrides block that getDefaultConfig()
had. Both now emit the identical, complete config.

configs/config.example.json stays separate on purpose — it is a documented
superset (cost_routing, aws_bedrock, extra models/overrides) and enables
cost routing, so it can't be the runtime default. To keep it honest, a new
test asserts every model alias shared between the example and the embedded
default is defined identically; this surfaced and fixed stale/missing vision
flags on glm-5.2, qwen3.7-plus, qwen3.7-max, and kimi-k2.7-code.

Tests:
- TestDefaultAndOpenCodeGoConfigsIdentical — the two generators match
- TestExampleConfigSharedModelsMatchDefault — example vs default drift guard
- TestKimiK3InDefaultConfig — kimi-k3 alias + fallback present

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@samueltuyizere
samueltuyizere merged commit 1ac5a93 into main Jul 17, 2026
3 checks passed
@samueltuyizere
samueltuyizere deleted the add-kimi-k3 branch July 17, 2026 10:44
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