Skip to content

Conversation

@seilk
Copy link
Contributor

@seilk seilk commented Jan 15, 2026

Summary

This PR builds on #8497 and addresses @rekram1-node's feedback from #8248:

"There are a LOT of providers that don't have this issue... ideally this would be strictly limited to litellm"

Instead of injecting the _noop tool unconditionally for all providers, this change restricts it to only LiteLLM-backed providers.

Problem

#8497 injects the _noop tool unconditionally when message history contains tool calls. While this fixes the LiteLLM compatibility issue, it unnecessarily affects providers that don't need it (Anthropic native, OpenRouter, Vertex, Bedrock, etc).

Solution

Add litellmProxy provider option and restrict _noop injection to LiteLLM providers:

const isLiteLLMProxy =
  provider.options?.["litellmProxy"] === true ||
  input.model.providerID.toLowerCase().includes("litellm") ||
  input.model.api.id.toLowerCase().includes("litellm")

if (isLiteLLMProxy && Object.keys(tools).length === 0 && hasToolCalls(input.messages)) {
  tools["_noop"] = tool({ ... })
}

Detection methods:

  1. Auto-detect: Provider ID or API ID contains "litellm"
  2. Explicit opt-in: Provider has litellmProxy: true option (for custom gateways)

Config example:

{
  "provider": {
    "my-gateway": {
      "api": "openai",
      "options": {
        "litellmProxy": true
      }
    }
  }
}

Changes

File Change
packages/opencode/src/session/llm.ts Add isLiteLLMProxy check with auto-detection + opt-in support
packages/opencode/src/session/message-v2.ts Handle pending/running tool calls (from #8497)
packages/opencode/test/session/llm.test.ts Tests for hasToolCalls helper (from #8497)
packages/opencode/test/session/message-v2.test.ts Tests for pending/running tool conversion (from #8497)

Testing

  • All tests pass (18 tests across 2 files)
  • Manual testing with custom LiteLLM gateway confirmed working

Related

Co-authored-by: Mark Henderson Mark.Henderson99@hotmail.com

seilk and others added 2 commits January 15, 2026 20:14
- Add dummy _noop tool when message history contains tool calls but no tools provided
- Convert pending/running tool calls to error results in toModelMessage
- Add hasToolCalls helper and comprehensive tests

Co-authored-by: Mark Henderson <Mark.Henderson99@hotmail.com>
Fixes anomalyco#8246
Fixes anomalyco#2915
…lity

Allow users to explicitly enable LiteLLM proxy compatibility for providers
that don't have 'litellm' in their ID (e.g., custom gateways).

Config example:
  provider.mygateway.options.litellmProxy = true

This restricts the _noop tool injection to only apply when:
1. Provider ID or API ID contains 'litellm' (auto-detected)
2. Provider has explicit 'litellmProxy: true' option (opt-in)
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Related PR Found

PR #8497: fix: handle dangling tool_use blocks for LiteLLM proxy compatibility

Why it's related:

Note: This is a related follow-up PR, not a duplicate. They work together to provide progressive enhancement of LiteLLM proxy support.

input: part.state.input,
errorText: "[Tool execution was interrupted]",
callProviderMetadata: part.metadata,
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is 100% a bug elsewhere but we can add this for now, this shouldn't ever happen

@rekram1-node
Copy link
Collaborator

Can we close ur other pr now?

@rekram1-node rekram1-node merged commit 1fa4deb into anomalyco:dev Jan 15, 2026
3 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 15, 2026
…lity (#8658)

Co-authored-by: Mark Henderson <Mark.Henderson99@hotmail.com>
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
@rekram1-node
Copy link
Collaborator

rekram1-node commented Jan 15, 2026

We should probably also document this, another idea tho we could update this:

export function error(providerID: string, error: APICallError) {

To handle litellm related errors (by doing some string matching) and maybe providing some better feedback for user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants