Skip to content

fix(agent-core-v2): fall back to protocol default base URL when unconfigured - #1632

Merged
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:fix/v2-fork-and-tool-dedupe
Jul 13, 2026
Merged

fix(agent-core-v2): fall back to protocol default base URL when unconfigured#1632
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:fix/v2-fork-and-tool-dedupe

Conversation

@sailist

@sailist sailist commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — the problem is explained below.

Problem

In agent-core-v2, a structured model whose provider has no base_url configured (neither in config, provider, nor env) was rejected with CONFIG_INVALID ("missing a base URL"). This is a regression from v1, where provider-manager let providers without a configured base_url fall back to their protocol's official default endpoint (e.g. the official Anthropic / OpenAI endpoints). Users migrating such configs to v2 hit a hard config error instead of the previous working behavior.

What changed

  • ModelResolverService: removed the CONFIG_INVALID throw when a structured provider resolves no base URL; resolvedBaseUrl is now string | undefined and the wire provider applies its protocol default endpoint, matching v1's provider-manager.
  • Guarded the Anthropic /v1 stripping so it only runs when a base URL actually exists.
  • Threaded the optional baseUrl through the Model, ModelImpl, ProtocolAdapterConfig, and buildProtocolProviderOptions types.
  • Added tests: every protocol type (anthropic, openai, openai_responses, kimi, google-genai) without base_url resolves to undefined; an anthropic-protocol override without base_url is left untouched; and flat models with neither providerId nor baseUrl are still rejected as before.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

…figured

- drop the "missing a base URL" rejection in ModelResolverService so a
  structured provider without base_url resolves to undefined and the wire
  provider applies its protocol default endpoint, matching v1
- relax baseUrl to optional across Model, ModelImplInit, and
  ProtocolAdapterConfig; guard the anthropic /v1 strip against undefined
@changeset-bot

changeset-bot Bot commented Jul 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ba87e6c

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

This PR includes changesets to release 4 packages
Name Type
@moonshot-ai/agent-core-v2 Patch
@moonshot-ai/kimi-code Patch
@moonshot-ai/kap-server Patch
@moonshot-ai/klient 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

@pkg-pr-new

pkg-pr-new Bot commented Jul 13, 2026

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

commit: ba87e6c

@sailist
sailist merged commit a4aae87 into MoonshotAI:main Jul 13, 2026
15 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 14, 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