Skip to content

fix(config): reject doubled provider prefixes in agent model ids #334

@w7-mgfcode

Description

@w7-mgfcode

Summary

Runtime config accepted a malformed agent model id with a doubled provider prefix, which then produced a 404 from the Gemini API at agent-run time.

Details

  • PATCH /config/ai persisted agent_default_model = google-gla:google-gla:gemini-3-flash-preview (returned 200).
  • PydanticAI treated the first google-gla: as the provider and sent google-gla:gemini-3-flash-preview as the model name.
  • Google returned: 404 NOT_FOUND — models/google-gla:gemini-3-flash-preview is not found for API version v1beta, or is not supported for generateContent.
  • Net effect: the primary model is unusable until the id is hand-corrected; the failure only surfaces when the agent is invoked (not at config-save time).

Expected

Config validation should reject or normalize a doubled provider prefix in agent_default_model / agent_fallback_model:

  • Reject (422) ids where the provider prefix appears more than once (e.g. google-gla:google-gla:...), or
  • Normalize by collapsing a duplicated leading provider prefix.
  • Apply to all supported providers (google-gla, google-vertex, anthropic, openai).

Tests

  • Schema-level: validator rejects/normalizes doubled-prefix ids.
  • Service-level: PATCH /config/ai with a doubled prefix returns 422 (or stores the normalized value).
  • Route-level: happy path + the doubled-prefix error path.

Context

Found while investigating an experiment-agent stream failure ("All models from FallbackModel failed"). The doubled prefix was the primary-model leg of that failure. Companion issue covers surfacing fallback sub-errors to the UI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions