Skip to content

fix(model-provider): handle unknown providers by defaulting to openai-compatible - #1823

Merged
ulivz merged 1 commit into
mainfrom
fix/issue-1822-models-undefined
Feb 27, 2026
Merged

fix(model-provider): handle unknown providers by defaulting to openai-compatible#1823
ulivz merged 1 commit into
mainfrom
fix/issue-1822-models-undefined

Conversation

@cjraft

@cjraft cjraft commented Feb 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fix the "Cannot read properties of undefined (reading 'models')" error when using custom OpenAI-compatible providers like kimi
  • When users specify an unknown provider, the model resolver now correctly defaults to openai-compatible as the base provider
  • Add test case for custom provider scenarios

Root Cause

When using a custom provider like kimi that is not in the predefined provider list, getActualProvider() returned the original provider name as baseProvider. However, this provider doesn't exist in the models object from @tarko/llm-client, causing models['kimi'].models to throw "Cannot read properties of undefined".

Solution

Modified getActualProvider() in model-resolver.ts to:

  1. First check if there's a high-level config that extends a base provider
  2. Then check if the provider is a known base provider
  3. For unknown providers, default to 'openai-compatible'

Test plan

  • Added unit test for kimi provider scenario
  • All existing tests pass (43 tests)
  • Build succeeds

Fixes #1822

@netlify

netlify Bot commented Feb 27, 2026

Copy link
Copy Markdown

Deploy Preview for tarko canceled.

Name Link
🔨 Latest commit aad1c6b
🔍 Latest deploy log https://app.netlify.com/projects/tarko/deploys/69a127f5af76e50008d79831

@netlify

netlify Bot commented Feb 27, 2026

Copy link
Copy Markdown

Deploy Preview for agent-tars-docs canceled.

Name Link
🔨 Latest commit aad1c6b
🔍 Latest deploy log https://app.netlify.com/projects/agent-tars-docs/deploys/69a127f4020f3b000825c670

@cjraft
cjraft requested review from ZhaoHeh and ulivz February 27, 2026 05:09
@cjraft
cjraft force-pushed the fix/issue-1822-models-undefined branch from 61f36ed to bac32ba Compare February 27, 2026 05:11
…-compatible

When users specify a custom provider like 'kimi' that is not in the
predefined provider list, the model resolver now correctly defaults
to 'openai-compatible' as the base provider instead of returning the
unknown provider name directly.

This fixes the "Cannot read properties of undefined (reading 'models')"
error that occurred when using custom OpenAI-compatible providers.

Also updates .secretlintrc.json to allow test placeholder API key values
(like 'test-key', 'kimi-api-key') while keeping security checks active
for the test directory.

Fixes #1822
@cjraft
cjraft force-pushed the fix/issue-1822-models-undefined branch from bac32ba to aad1c6b Compare February 27, 2026 05:13
@ulivz
ulivz merged commit 239b654 into main Feb 27, 2026
10 checks passed
@ulivz
ulivz deleted the fix/issue-1822-models-undefined branch February 27, 2026 05:19
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.

[Bug Report]: AgentRunner [Stream] Error in agent loop execution: TypeError: Cannot read properties of undefined (reading 'models')

2 participants