MoonshotAI / MoonshotAI/kimi-code

Main agent K3 requests routed to 256K kimi-for-coding backend after subagent/AgentSwarm returns

Open
#3,496 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

Version

0.40.1

Platform

Linux x86_64

Model

Main agent: kimi-code/k3 (status bar shows K3)

What happened

In two separate sessions, the main agent's llm.request wire records always show modelAlias: "kimi-code/k3" and model: "k3", but the request was rejected by the backend with:

400 Invalid request: Your request exceeded model token limit: 262144 (requested: ...)

At the same time, my Kimi Code console's model-usage records show these main-agent requests were actually served as k2.7 code (kimi-for-coding), which has a 256K context limit.

Trigger pattern observed

In both cases, the error happened immediately after a subagent using kimi-code/kimi-for-coding returned:

  1. Session session_76a8b5ca-4efe-466b-8e4e-514576e44de8

    • Turn 31 step 5 called Agent (description: "修复 K1+R2 review 问题", model kimi-code/kimi-for-coding).
    • Step 5 ended at 2026-09-02 10:25:03 UTC with ~520K input tokens.
    • Step 6 at 2026-09-02 10:25:05 UTC failed with:
      model token limit: 262144 (requested: 501524)
      
  2. Session session_01a1ce7b-441e-4d4b-9b52-38cf39cd40f4

    • Turn 4 step 3 called AgentSwarm (description: "anima LoRA NSFW 调研打标", subagent model kimi-code/kimi-for-coding).
    • Step 3 ended at 2026-09-03 03:28:39 UTC.
    • Step 4 at 2026-09-03 03:28:40 UTC failed with:
      model token limit: 262144 (requested: 322518)
      
Expected behavior

When the main agent is bound to kimi-code/k3, its requests should always be routed to the K3 (1M context) backend, regardless of whether Agent/AgentSwarm subagents using other models were invoked earlier in the same session.

Additional context
  • The client-side wire log always records model: "k3" for the failing main-agent requests, so this does not look like the client changed the requested model.
  • It looks like either the managed:kimi-code provider backend is routing the session to a k2.7 code deployment after a subagent uses it, or some session/provider-level state is leaking from the subagent model back to the main agent.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the llm.request path and the Agent and AgentSwarm model/provider handling, comparing main-agent state before and after a kimi-code/kimi-for-coding subagent returns. The issue is done when main-agent kimi-code/k3 requests consistently reach the K3 backend after either subagent flow, with regression coverage for both observed patterns.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.