magpie icon indicating copy to clipboard operation
magpie copied to clipboard

[Feature request] per-model compat / inputLimits passthrough in the agent model lists magpie generates

Open cuipengcx90 opened this issue 1 month ago • 2 comments

Feature request: per-model compat / inputLimits passthrough, and full thinkingLevelMap control

What I'm doing

I use magpie as the single source of truth for every coding agent on this machine. After migrating pi to magpie-only (deleting all 16 native providers from ~/.pi/agent/models.json, leaving only providers.magpie that magpie generates), everything works — context windows, output limits, efforts, names, prices and headers all come from magpie.

Two things still cannot be expressed in magpie, so they have to be hard-coded in an agent-side extension (magpie-compat.ts in pi) that re-registers the provider on top of what magpie writes. That's the opposite of "one source of truth", and it silently drifts whenever magpie rewrites the model list.

Gap 1: compat

magpie writes compat for only 8 of 57 models, and the only key it sets is its own computed forceAdaptiveThinking. Everything else has to stay in the agent.

These keys change wire behavior, not just display:

key what breaks without it
supportsMidConvoSystemMessages pi reorders/merges mid-conversation system messages → the context prefix changes → prompt cache misses every turn (measured, painful)
supportsStore / supportsDeveloperRole wrong fields sent to relays that reject them
maxTokensField (max_tokens vs max_completion_tokens) 400 from strict relays
thinkingFormat (deepseek) reasoning content not echoed back correctly
sessionAffinityFormat (openai-nosession) session headers sent to relays that don't accept them
requiresReasoningContentOnAssistantMessages replay of assistant turns rejected

In the pi model: 34 of 57 models need at least one of these, and 26 need supportsMidConvoSystemMessages.

Gap 2: inputLimits

inputLimits is never written by magpie (0/57 here). Without it agents fall back to their own defaults for image resizing (pi: 2000×2000, 4.5 MiB, JPEG q80). Some relays reject larger images, some accept only smaller ones.

Gap 3: thinkingLevelMap

magpie model efforts <provider/model> low,medium,high only accepts levels the vendor declared. Several providers here declare low,high,max while the agent needs a remap such as minimal→low, medium→high, xhigh→max. Currently magpie model efforts rejects those with has no reasoning level "medium", so those remaps also stay in the agent.

(Related, already open: #1693 asks for adding levels to a model with known levels — same area, might be solved together.)

Note: #1103 (closed) already covers the "catalog sync rewrites providers.magpie" part — I'm not re-asking for that. I'm asking for a place to put these values so a rewrite doesn't lose them.

Suggested shape (any of these would fix it)

  1. A per-model JSON passthrough, merged verbatim into the model entry magpie writes into each agent:
    magpie model extra <provider/model> '{"compat":{"supportsMidConvoSystemMessages":true},"inputLimits":{...}}'
    
  2. Or per-provider defaults plus per-model overrides:
    magpie provider set <id> compat.supportsStore=false
    magpie provider set <id> inputLimits.images.resize.maxWidth=1568
    
  3. For efforts, allow arbitrary mapping instead of only the vendor's declared set:
    magpie model efforts <provider/model> minimal=low,medium=high,xhigh=max
    

Whichever shape you pick, the values must be written through to the agent's model list exactly like contextWindow / maxTokens already are.

Environment

  • magpie 0.1.1290 (macOS arm64)
  • agents affected: pi (~/.pi/agent/models.json), and the same fields exist in other agents' providers
  • related: magpie-compat.ts in pi currently works around all three gaps; the workaround is ~40 lines of a lookup table that has to be regenerated by hand

Happy to test a build if that helps.

cuipengcx90 avatar Oct 19 '26 03:10 cuipengcx90

Bug: magpie claude haiku writes a [1m] suffix onto a model that has no 1M variant

Found while migrating everything to magpie-only. 4router serves claude-haiku-5-5 but not claude-haiku-5-5[1m] (only sonnet/opus have the [1m] variant).

$ magpie claude haiku '4router/claude-haiku-5-5'
✓ Claude Code haiku 4router/claude-haiku-5-5[1m] (unchanged)

It reports unchanged yet the value stays 4router/claude-haiku-5-5[1m], which is not in magpie's model list for that provider. The same happens for ANTHROPIC_SMALL_FAST_MODEL.

Effect: ANTHROPIC_DEFAULT_HAIKU_MODEL and ANTHROPIC_SMALL_FAST_MODEL in ~/.claude/settings.json point at a model magpie cannot resolve, so Claude Code's haiku tier (background/small tasks) breaks. Main model is unaffected.

Workaround I'm using: after any magpie claude <field> write, hand-fix those two env values back to 4router/claude-haiku-5-5.

Suggestion: only append [1m] when the provider actually exposes a [1m] variant for that model (or when the chosen model id already carries it), and don't report unchanged when the written value differs from what was asked.

cuipengcx90 avatar Oct 19 '26 05:10 cuipengcx90

Adding a Pi-specific modelOverrides usage case that may help people affected by this request. This comment was prepared with AI assistance; the observations below come from recorded isolated runs, not a new test of the latest release.

Environment: Windows amd64, Pi 1.5.0, Magpie v0.1.2115 (revision cdf8151a2e0c3c48191481272dbaee0c210e989a).

Instead of placing a manual compat flag only inside the generated providers.magpie.models[] entry, I put it in Pi's existing provider-level modelOverrides in ~/.pi/agent/models.json. Schematic fragment, to merge into the existing provider rather than replace the file:

{
  "providers": {
    "magpie": {
      "modelOverrides": {
        "<existing-model-id>": {
          "compat": {
            "forceAdaptiveThinking": true
          }
        }
      }
    }
  }
}

<existing-model-id> is a placeholder for the exact id in the generated model list. The flag is only an example for a separately verified endpoint, not a recommendation to enable adaptive thinking for every model or relay.

Using the installed Magpie binary with isolated configuration:

  • A Pi model switch and two catalog rewrites retained all 14 tested per-model overrides, whereas the manually added flag inside the generated models[] entry was regenerated away.
  • A separate explicit compat.forceAdaptiveThinking: false override also survived a catalog rewrite.
  • Pi's actual model loader applied the true overrides. The production configuration was unchanged during these isolated rewrite tests.

This gives Pi users a persistent local workaround for the tested flag. It is not a Magpie-native per-model configuration command, does not establish arbitrary-field passthrough, and does not verify inputLimits, other compat keys, arbitrary effort remapping, or other agents. I have not repeated these runtime tests with the latest Magpie release.

So the broader request still seems useful: a documented, Magpie-managed configuration surface would avoid keeping agent-specific overrides separately. Sharing this narrower case rather than treating the whole feature request as already implemented.

hetingyi avatar Nov 08 '26 19:11 hetingyi