Skip to content

Pi engine OpenRouter example is rejected by the model identifier grammar #77514

Done

Description

@jansdhillon

Summary

The Pi engine reference documents OpenRouter in "Additional providers" with this model form:

engine:
  id: pi
  model: openrouter/anthropic/claude-sonnet-4
  model-provider: openai
  env:
    OPENAI_BASE_URL: https://openrouter.ai/api/v1
    OPENAI_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
network:
  allowed: [defaults, openrouter.ai]

This does not compile. The model identifier grammar (pkg/workflow/model_identifier.go, MAF spec) allows exactly one slash in provider/model-token, and the model token may not contain a slash. OpenRouter model ids are vendor-prefixed (for example moonshotai/kimi-k3), so the documented openrouter/vendor/model shape always fails:

engine.model: model identifier: character '/' is not allowed in model token "anthropic/claude-sonnet-4" (segment type: model)

Every vendor-prefixed OpenRouter id is therefore unexpressible through engine.model, which is all of them.

There is a second mismatch: pkg/workflow/pi_provider.go registers a native provider openrouter -> OPENROUTER_API_KEY, which suggests model: openrouter/ works without the custom-route env block. It does not: compilation fails with "engine 'pi' provider openrouter has no credential-isolated AWF route; configure engine.model-provider and a compatible custom API target, or explicitly disable the agent sandbox".

Environment

  • gh-aw v0.89.21 (gh extension) and v1.2.2 (latest release); both reproduce
  • ubuntu-latest, public repository

Reproduction

  1. Create a workflow with the documented frontmatter above (or any openrouter// model)
  2. Run gh aw compile <workflow>
  3. Compilation fails with the model token error above

The only form accepted by the grammar is a single-slash id, for example model: openrouter/kimi-k3 with the custom route env block. It is unclear whether that resolves at runtime to the vendor-prefixed OpenRouter catalog id (moonshotai/kimi-k3) or fails the AWF /reflect exact-id check.

Expected

Either the documented example compiles (grammar accepts provider/vendor/model, or OpenRouter routing resolves bare tokens against the vendor-prefixed catalog), or the docs show the actually supported form and spell out how vendor-prefixed OpenRouter ids are addressed.

Actual

Docs example fails validation on current and latest gh-aw; the native provider registry entry suggests a shorter config that also fails validation; the working subset and its runtime behavior are undocumented.

Activity

  1. locked and limited conversation to collaborators on Nov 13, 2026
  2. unlocked this conversation on Nov 13, 2026
  3. jansdhillon commented on Nov 13, 2026

    @jansdhillon
    Author

    Confirmed both halves of this, and can answer the open runtime question: the single-slash form does not work either, so there is no supported way to run an OpenRouter model on the pi engine today.

    Compile-time. ParseModelIdentifier (pkg/workflow/model_identifier.go) splits the base on the first slash with strings.Cut, validates the rest as model-token, and reModelToken (^[A-Za-z0-9][A-Za-z0-9_-]*(\.[A-Za-z0-9][A-Za-z0-9_-]*)*$) admits no slash. So openrouter/moonshotai/kimi-k3 parses as provider openrouter, model token moonshotai/kimi-k3, and fails with character '/' is not allowed in model token "moonshotai/kimi-k3". The grammar is the only compile-time blocker.

    Runtime (the question the issue leaves open). The single-slash openrouter/kimi-k3 compiles, but fails the gateway availability check in the agent job. pi_models_json.cjs strips only the leading provider prefix (configuredModel.slice(modelSlash + 1)), leaving kimi-k3, and validatePiModelAvailability looks that bare id up in the endpoint's advertised models. The OpenRouter endpoint only ever advertises vendor-prefixed ids (moonshotai/kimi-k3, openai/gpt-5, anthropic/claude-...); there is no bare kimi-k3, so the check fails with "Pi model "kimi-k3" is not advertised by the configured openai proxy endpoint". Verified against the live /api/v1/models catalog (471 models, all kimi ids are moonshotai/*) and the run's awf-reflect.json (291 models on the openai endpoint, all vendored). The alias path does not help either: the built-in kimi alias resolves to openai/kimi*, which glob-matches nothing because no openai/-prefixed kimi exists on the endpoint.

    Net: the vendored form is rejected at compile time and the bare form is rejected at runtime, so no OpenRouter model is expressible on pi. Note the codex engine compiles the vendored form (model: moonshotai/kimi-k3) without error, so this is specific to the pi/MAF grammar path.

    A minimal fix that resolves both halves: allow exactly one inner slash in model-token (a single vendor segment), so openrouter/moonshotai/kimi-k3 parses as provider openrouter + model moonshotai/kimi-k3. Both the Go parser and the JS availability check already split on the first slash only, so the vendored remainder flows through to the catalog lookup unchanged and matches. The spec (docs/src/content/docs/specs/model-alias-specification.md) would need the model-token rule amended to permit one vendor segment; the prose already anticipates the vendor/model convention (section 90). Happy to open a PR for the grammar + spec + a pi engine regression test if that direction sounds right.

  4. 55 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions