Skip to content

feat(agent-core): ModelProvider interface and SingleModelProvider - #167

Merged
kermanx merged 9 commits into
mainfrom
refactor/constructable-agent
May 28, 2026
Merged

feat(agent-core): ModelProvider interface and SingleModelProvider#167
kermanx merged 9 commits into
mainfrom
refactor/constructable-agent

Conversation

@kermanx

@kermanx kermanx commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Decouple Agent from ProviderManager by introducing a ModelProvider interface, so that Agent can be constructed independently of a full Session / ProviderManager lifecycle.

What changed

  • New ModelProvider interface – abstracts model resolution and optional auth away from ProviderManager.
  • New SingleModelProvider – a lightweight implementation for single-model scenarios (e.g. headless tests or standalone agents).
  • ProviderManager now implements ModelProvider – existing session-based behavior is preserved.
  • Agent constructor updates:
    • providerManagermodelProvider (type changed to ModelProvider).
    • skills is now SkillManager | null instead of SkillManager | undefined.
    • Removed unused cronSessionDir option.
    • Reordered fields for clarity.
  • Removed modelName from ResolvedRuntimeProvider – callers already have the alias, so the field was redundant.
  • Auth resolver renamedcreateAuthResolverForModelresolveAuth on ModelProvider.
  • Tests and harnesses updated to use the new modelProvider field.

Why

Previously Agent required a ProviderManager instance, which in turn needs a full Session setup. This made it impossible to construct a usable Agent outside of a session. With ModelProvider, Agent becomes independently constructable – useful for testing, sub-agents, and future headless modes.

@changeset-bot

changeset-bot Bot commented May 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2fa39d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/agent-core Patch
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kermanx kermanx changed the title refactor(agent-core): make Agent constructable feaet(agent-core): ModelProvider interface and SingleModelProvider May 28, 2026
@kermanx kermanx changed the title feaet(agent-core): ModelProvider interface and SingleModelProvider feat(agent-core): ModelProvider interface and SingleModelProvider May 28, 2026
@pkg-pr-new

pkg-pr-new Bot commented May 28, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@2fa39d1
npx https://pkg.pr.new/@moonshot-ai/kimi-code@2fa39d1

commit: 2fa39d1

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4620122725

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agent-core/src/agent/config/index.ts
Comment thread packages/agent-core/src/agent/turn/index.ts
Comment thread packages/agent-core/src/session/provider-manager.ts

resolveProviderConfig(model: string): ResolvedRuntimeProvider {
if (model !== this.providerConfig.model) {
throw new Error(`Model "${model}" is not supported by SingleModelProvider.`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return a KimiError for unsupported standalone models

When a standalone agent uses SingleModelProvider and the caller selects any other model (for example via setModel), this plain Error crosses the RPC boundary as ErrorCodes.INTERNAL instead of the model-configuration error that the ProviderManager path returns. That makes a simple unsupported-model selection look like an internal failure to SDK/TUI callers. Please throw a KimiError with the appropriate config/model code here.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0680d4012d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/agent-core/src/agent/tool/index.ts
Comment thread packages/agent-core/src/agent/index.ts
@kermanx
kermanx merged commit b5981a5 into main May 28, 2026
6 checks passed
@kermanx
kermanx deleted the refactor/constructable-agent branch May 28, 2026 14:27
@github-actions github-actions Bot mentioned this pull request May 28, 2026
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