Skip to content

WS2 item 4: wire run_agent.py provider profile activation (incremental) #14515

@kshitijk4poor

Description

@kshitijk4poor

Problem

PR #14424 adds providers/ package with 8 provider profiles and a transport single-path (_build_kwargs_from_profile). The profiles are proven correct via 73 parity tests. However, wiring run_agent.py to activate profiles caused 50 test regressions because of a fundamental detection mismatch.

The mismatch

Legacy detection: URL pattern matching

_is_nvidia = "integrate.api.nvidia.com" in self._base_url_lower
_is_kimi = base_url_host_matches(self.base_url, "api.kimi.com") or ...
_is_qwen = self._is_qwen_portal()  # checks base_url

Profile resolution: Provider name matching

_profile = get_provider_profile(self.provider)  # "nvidia", "openrouter", etc.

A user with provider="custom" and base_url="https://integrate.api.nvidia.com/v1" hits the NVIDIA path in legacy but gets NO profile. Conversely, tests that set provider="openrouter" without a matching base_url now hit the profile path when they expected legacy.

Missing params in profile path

The legacy chat_completions _build_api_kwargs computes these agent-level params that the profile path doesn't:

  1. anthropic_max_output — Claude max output for OpenRouter/Nous (calls _get_anthropic_max_output)
  2. qwen_session_metadata — Random UUID per call
  3. supports_reasoning — Model-family-gated reasoning safety check
  4. github_reasoning_extra — GitHub Models reasoning config
  5. _fixed_temperature_for_model — Temperature override from auxiliary_client
  6. provider_preferences — OpenRouter provider routing preferences

Proposed approach

Wire profiles one provider at a time, simplest first:

  1. NVIDIA (only default_max_tokens, zero missing params)
  2. DeepSeek (minimal profile, zero extras)
  3. Kimi (OMIT_TEMPERATURE + reasoning_effort — profile handles both)
  4. Qwen (needs session_metadata generation in profile)
  5. OpenRouter (needs anthropic_max_output + supports_reasoning + provider_preferences)
  6. Nous (similar to OpenRouter)

Each wiring step: add the missing params to the profile, write an E2E test that calls _build_api_kwargs with real agent state, verify identical output, then enable.

Acceptance criteria

  • Each provider profile produces identical build_kwargs output to the legacy flag path
  • Tests that create agents with provider="X" work correctly on the profile path
  • provider="custom" with provider-specific base_url still hits legacy path (profile returns None)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions