Skip to content

pi harness gateway path collapses multi-family providers to anthropic-only, breaking non-Anthropic models (404 with no body) #5359

Description

@angiarao

Summary

When a provider config declares both an anthropic: and openai: family, _apply_provider_to_pi (omnigent/runtime/workflow.py) always selects anthropic: as pi's single auth/base-URL source, regardless of which model the agent spec actually requests. Any non-Anthropic model then gets routed to the anthropic-messages endpoint and fails with a bare 404 status code (no body).

Root cause

The current gateway can serve multiple models, both Anthropic and OpenAI-family, from the same base URL. PiExecutor's gateway path generates a fresh models.json into a temp PI_CODING_AGENT_DIR, built entirely from HARNESS_PI_GATEWAY_BASE_URLS — which _apply_provider_to_pi populates with at most one family's base URL, preferring anthropic: whenever both are present on the provider. This throws away pi's native ability to route different models to different wire protocols from a single models.json.

Repro

  1. Configure one provider with both families pointed at the same gateway base URL:
    providers:
      my-gateway:
        anthropic: {api_key_ref: ..., base_url: https://gateway.example.com/}
        openai:    {api_key_ref: ..., base_url: https://gateway.example.com/, models: {default: some-glm-model}, wire_api: chat}
        default: true
        kind: gateway
  2. Run an agent with executor: {model: some-glm-model, auth: {type: provider, name: my-gateway}, config: {harness: pi}}
  3. Observe inner executor error: 404 status code (no body)

Current workaround

Split into two providers, one per family, and pin the right one per agent spec via executor.auth. Works, but forces N providers for N wire families sharing one gateway.

Suggested fix

_apply_provider_to_pi (or PiExecutor._build_models_json) should emit a models.json with one entry per configured family, each carrying its own base URL/auth/wire API, instead of collapsing to a single family upfront.

Environment

  • Harness: pi (SDK/headless path via PiExecutor)
  • Relevant files: omnigent/runtime/workflow.py::_apply_provider_to_pi, omnigent/inner/pi_executor.py::_build_models_json

Metadata

Metadata

Assignees

Labels

BugSomething isn't workingP2-mediumPriority: bug with workaround, important feature requestcomp:harness-t2Mainline harnesseshelp wantedExtra attention is neededtriagedIssue has been triaged by the bot

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions