Skip to content

(bug) A custom provider's model list can shadow a working standard key, and ambiguous matches run with no credential #5117

Description

@mmabrouk

Two related connection-resolution bugs found while probing custom-provider connections: a custom provider's model list can shadow a working standard key, and a genuinely ambiguous match runs with no credential instead of failing loud.

1. A custom provider's model list can shadow a working standard key

Steps to reproduce

  1. Create a standard OpenAI vault connection with no slug (the common project-default case).
  2. Also create a custom-provider connection whose models list happens to include a model name the standard key also serves (for example gpt-4o-mini), also with no slug.
  3. Run against gpt-4o-mini.

Observed

The custom-provider connection resolves first, even though the standard OpenAI key would have worked and is what the user most likely intended.

Where this lives

sdks/python/agenta/sdk/agents/platform/connections.py_candidate_pool (around lines 364-378) filters candidates by model-name match first and only falls back to provider match if there's no model match. For slug-less default connections this lets a custom provider's models list outrank a standard key's provider-family match.

Suggested fix: for slug-less default connections, rank a provider-family match on a standard key above a model-name match on a custom provider.

2. Ambiguous resolution is swallowed and the run proceeds with no credential

Steps to reproduce

  1. Create two connections that both resolve for the same provider/mode combination such that resolve_connection raises AmbiguousConnectionError, on a slug-less (default) connection.
  2. Run against that provider/model.

Observed

services/oss/src/agent/app.py_resolve_session_connection's except ConnectionResolutionError branch (which AmbiguousConnectionError falls under) logs a warning and degrades to credential_mode="runtime_provided" with an empty env, exactly as it does for a genuinely missing default connection. The run proceeds with no credential injected at all, and the user later sees a generic "add your key" auth error — nothing tells them the real problem was an ambiguous match between two of their own connections.

Suggested fix: don't fold AmbiguousConnectionError into the same tolerant-degrade path as "no connection configured" — surface it as the run's actual failure reason so the user knows which connections are conflicting.

Context

Found while probing custom-provider connections end to end against the dev stack (2026-07-07). Surfaced by the new connect-model drawer in #5096, which makes it much easier to end up with multiple overlapping connections. Related: this is one of five connection gaps found in the same investigation — see also the Pi-side and Claude-side issues.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions