Skip to content

Provider-specific API key format validation #5455

@kshitijk4poor

Description

@kshitijk4poor

Problem

has_usable_secret() only filters obvious placeholders (empty, "changeme", "dummy"). It does not validate provider-specific key formats. A garbled or wrong-provider key (e.g. an OpenAI key pasted into ANTHROPIC_API_KEY) passes the filter and fails on the first API call with a cryptic 401.

Proposed Solution

Add lightweight prefix/format checks for known providers:

  • OpenAI: starts with sk- (classic) or sk-proj- (project)
  • Anthropic: starts with sk-ant-
  • OpenRouter: starts with sk-or-

Emit a warning during provider resolution if the key does not match the expected format. Advisory only — do not block, since providers may change formats.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havearea/configConfig system, migrations, profilescomp/agentCore agent loop, run_agent.py, prompt buildertype/featureNew feature or request

    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