Skip to content

Upstream kimi-code — Daily Summary (2026-07-26): agent-core-v2 DI refactor #8

Description

@zicochaos

Upstream changes (since c497af60e, 2026-07-25)

Upstream advanced by 2 commits (git fetch upstream main; new tip bf8e967d5, 2026-07-26). Both are large agent-core-v2 DI refactors by Haozhe — combined they touch 362 files.

🏗️ agent-core-v2 — DI / scope lifecycle refactor (2 themes, entangled)

Theme A — Per-scope keyed state container (7799bd734, MoonshotAI#2192)

  • Eager scope instantiation: every service registered for a scope tier is now constructed at scope creation (drops the hand-maintained eager lists in AgentLifecycleService, SessionLifecycleService, and the bootstrap kosong bridge).
  • New _base StateRegistry: typed StateKey/defineState descriptors, per-key onDidChange + global onDidChangeAny, with BugIndicatingError on duplicate/unregistered access. Bound as IStateService (App) / ISessionStateService (Session) / IAgentStateService (Agent).
  • State migration: plain-data fields of 13 session-scope services (cron, interaction, sessionActivity, agentProfileCatalog, fs, fsWatch, log, metadata, skillCatalog, toolPolicy, workspaceCommand, workspaceContext) moved into defineState keys. New StateRegistry.snapshot() for JSON-safe serialization.

Theme B — Tools as scoped services (bf8e967d5, MoonshotAI#2196)

  • Replaces module-level registerTool + AgentBuiltinToolsRegistrar with registerAgentTool (Agent-scope DI service + contribution table). New toolActivation domain: AgentToolActivationService filters contributions by the bound Profile's tool policy and re-activates on agent.status.updated.
  • Centralizes builtin tools under agent/tools/: tools moved from scattered domain folders (plan/tools, goal/tools, os/backends/node-local/tools, task/tools) into a unified directory; each split into a kebab-case definition (bash.ts) + registration (bashTool.ts).
  • BuiltinToolAgentTool service interface; tools become Agent-scope services with decorator-injected deps (e.g. AgentToolSubagentTool/ISubagentTool).
  • SyncDescriptor.instantiateWithScope opt-out so agent tools (which may legitimately throw if their host capability is missing, e.g. WebSearchTool) stay lazy despite the new eager-scope semantics from Theme A.

Note: the two themes are interdependent — Theme B's tool-laziness is a direct patch on Theme A's eagerness. Port one, port both.

Impact on this fork

The fork has 16 local commits (161 files) since the merge-base. A git merge-tree dry-run of upstream/main into main reports 6 content conflicts out of 16 overlapping files; the other 10 overlap files auto-merge cleanly.

Severity File Fork change (commits) Upstream change Conflict nature
🔴 High agent/tools/agent-swarm/agentSwarmTool.ts subagent model surfacing (353a1c573) moved + re-registered as scoped service (Theme B) fork edits a tool file upstream relocated & rewired; file may even be at a new path on each side
🔴 High agent/tools/agent/agentTool.ts subagent model (353a1c573) same tool relocation (Theme B) same — agent/subagent tool files are ground zero
🔴 High session/sessionSkillCatalog/skillCatalogService.ts disabled_skills denylist (b168c608e), catalog reload wait (410ce581f), plugin guidance (50c148327) service migrated to ISessionStateService (Theme A) fork added filtering/reload logic to a file upstream restructured for state-container migration
🟡 Med test/agent/swarm/swarm.test.ts subagent model test (353a1c573) test rewritten for new tool DI test edits collide; resolve by re-applying fork's assertions on upstream's new test shape
🟡 Med test/session/sessionSkillCatalog/skillCatalog.test.ts catalog reload/disabled-skills tests test updated for state-container migration same — fork's new tests need porting onto upstream's restructured fixtures
🟡 Med test/tool/tool.test.ts subagent model / exact-alias tests tool test rewritten for scoped-service registration same
🟢 Auto-merged apps/kimi-code/src/tui/components/messages/tool-call.ts subagent model display (353a1c573) TUI tool-call refactor merged cleanly — verify behavior post-merge
🟢 Auto-merged agent/profile/profileService.ts, agent/skill/skillService.ts, agent/plugin/agentPluginService.ts, app/kosongConfig/kosongConfigService.ts, index.ts, session/sessionInit/sessionInitService.ts, session/swarm/sessionSwarmService.ts + 4 test files various fork features various upstream refactors all auto-merge; spot-check that fork features still compile

Bottom line: The fork's subagent-model-selection work (353a1c573) and skills work (b168c608e/410ce581f/50c148327) sit squarely in the files upstream just relocated and rewired. Both lines of work touch the same tool registration + skill catalog plumbing, so this is a real rebase, not a clean merge.

Recommended follow-ups

  • Decide sync strategy: given 6 content conflicts across both entangled upstream themes, plan a single git merge upstream/main (don't cherry-pick — the two upstream commits depend on each other and touch 362 files). Do it on a fresh branch.
  • Port subagent-model work onto new tool locations (🔴): after merge, re-apply 353a1c573's subagent-model surfacing onto the relocated agent/tools/agent/agentTool.ts + agent/tools/agent-swarm/agentSwarmTool.ts and the new AgentTool/ISubagentTool DI wiring from Theme B. The fork's edits were against the old scattered tool layout.
  • Re-apply skills features onto state-container layout (🔴): port b168c608e (disabled_skills denylist), 410ce581f (catalog reload wait), 50c148327 (disabled plugin guidance) onto skillCatalogService.ts after upstream's ISessionStateService migration — the filtering logic likely needs to register its own defineState key now.
  • Reconcile 3 test files (🟡): rewrite the fork's swarm.test.ts / skillCatalog.test.ts / tool.test.ts assertions against upstream's new test fixtures (scoped-service registration, state-container stubs). Use upstream's new test/state/stubs.ts helper.
  • Verify the 10 auto-merged files: run pnpm -r build + the agent-core-v2, kap-server, and kimi-code test suites; the tool-call.ts TUI auto-merge especially needs a visual check that subagent model still renders.
  • Watch for disabled_skills semantic drift: upstream's new AgentToolActivationService filters by Profile tool policy — confirm the fork's disabled_skills denylist (config-driven) composes correctly with upstream's profile-driven filtering and isn't shadowed.

Upstream tip: bf8e967d5 (2026-07-26). Fork is 16 commits ahead, now 2 behind. Generated by daily upstream-summary automation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstream-syncUpstream MoonshotAI/kimi-code sync tracking

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions