Commit Graph
4 Commits
Author SHA1 Message Date
yetoneandggbdpq d5fea7f02e gateway: a relay whose list names gpt-image-2 under a namespace draws it (#4432)
loscoy's retest (v0.1.2670) still got 404 "magpie knows no model
"gpt-image-2" to draw with" for the bare name a Codex harness asks for:
the relay's cached list names the family under a namespace
(openai/gpt-image-1, openai/gpt-image-2 …), and drawsFamily, which
a130035a0 narrowed to a drawer whose id starts gpt-image-, read those as
none of the family, so the relay that draws was passed over.

drawsFamily now reads each drawer by the part of its id past the last
"/". The narrowing stands: only a relay whose own list draws a GPT Image
takes the family. A new drawnAs sends the relay the id its list names
the model by (openai/gpt-image-2 for gpt-image-2), on both the images
route (resolveDrawing) and Codex's native image tool (drawingModel);
a name the list doesn't carry goes as asked, for the vendor to serve or
refuse in its own words. ggbdpq's patch (via gua2100) sent the bare name
upstream; loscoy asked whether the namespace had to be kept, and a
relay that lists only openai/… may not know the bare one, so the listed
id is sent.

Run at this tree on mote: go test ./internal/gateway -run
'Draw|Drawing|Relay|Codex|UpBytes' -count=1: ok. gofmt -l clean.
Broken by hand: drawsFamily back to the whole id: TestRelayDrawsThe
GPTImageFamilyFromANamespacedList, TestCodexNativeDrawsItsOwnModelOnA
NamespacedRelay and TestCodexNativeDrawsByTheRelaysNamespacedName red;
drawnAs returning the bare id: the first and last red.
Not tried: loscoy's real relay; the namespaced id is what its list says,
not seen on its wire.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-03 05:08:38 +08:00
yetone a130035a0d gateway: only a relay whose list draws a GPT Image takes the family (#4432)
34199952b let any keyed provider at a Responses base draw every
gpt-image-* name. Its body says "a Codex backend relay whose model list
carries any gpt-image* name", but the code read no list: a chat-only
relay ahead of one that draws took a bare gpt-image-2 and failed it at
its vendor, and a Codex turn on a chat-only relay lost the Settings pick
it drew with before. The patch changed TestCodexDrawingFallsBackToImage-
Setting's expectations (and moved its "off" checks to no turn) to fit.

drawsFamily now takes a keyed Responses relay only when its own Drawers
hold one gpt-image-* already, as the patch's description had it. Both of
the patch's tests stay green; TestCodexDrawingFallsBackToImageSetting is
back to its form before the patch, and TestRelayDrawingNoGPTImageClaims-
NoneOfTheFamily covers the chat-only relay.

Run on mote: go test -tags nogui ./internal/gateway/ -run
'Draw|Drawing|Relay' ok. Broken by hand: the case returning true for any
gpt-image-* (the patch's rule) fails the new test (plain/gpt-image-2)
and TestCodexDrawingFallsBackToImageSetting (text-only/gpt-image-2);
the case removed fails the patch's two tests and the new one.
Not tried: a real sub2api relay (loscoy's), whose list magpie_image
drew from per the report.
2026-11-02 07:40:21 +08:00
ggbdpq 7e44e57b4e fix(gateway): a Codex backend's relay draws the gpt-image family it serves (#4432)
A harness asking for its own image model by the bare name its vendor
gives it (Codex CLI asks its provider for gpt-image-2) was turned away
by magpie when the provider is a Codex backend relay (sub2api) whose
model list names another of the family, or none: drawsFamily admitted
only a ChatGPT account and a Grok subscription, so resolveDrawing
answered 404 "magpie knows no model "gpt-image-2" to draw with", and a
Codex turn's own provider lost the drawing to magpie's Settings pick,
the harness's own model overridden. The relay serves the ChatGPT
backend's images API, which draws the same for any gpt-image-* name
(#1865), as #870 had it draw its listed ones; it draws the family the
same way, the vendor refusing in its own words one it doesn't serve.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-02 07:40:21 +08:00
maYandyetone 6fe8169502 gateway, agent: Codex draws with its native image tool through magpie (#870)
* fix(agent): give magpie's provider table the actor-authorization header

Codex offers its built-in image tool (image_gen.imagegen) — and the other
OpenAI-provider tools — only to a provider it reads as the OpenAI actor:
ModelProviderInfo::uses_openai_actor_authorization(), i.e. a provider that
does not require OpenAI auth but carries x-openai-actor-authorization.
magpie writes [model_providers.magpie] but carried neither signal, so a
Codex on magpie was never given the tool and could not draw through a
Codex backend such as sub2api's.

Write http_headers = { "x-openai-actor-authorization" = "magpie" } into
that table. magpie does not forward the header upstream: codexHeader
rejects anything naming "authorization".

Test: TestCodexMagpieProviderCarriesActorAuthorization.

* gateway/provider: let a Responses-only relay (Codex backend, sub2api) draw

A provider added as 'OpenAI Responses' only (what a Codex backend such as
sub2api speaks) has no chat base, so Drawers() returned nil before ever
looking at the vendor's list, draw() refused with 'can't draw', and
drawImages() posted to an empty base. The vendor's own /v1/models does list
its image models (sub2api serves gpt-image-2.5), and they are meant to be
picked in Settings → Images.

- Drawers: a Responses-only provider draws when it has any OpenAI-shaped
  base, not only a chat one.
- draw: refuse only when neither Chat nor Responses is set.
- drawImages: fall back to the Responses base when there is no chat base.
- List: the add form's 'Fetch models' keeps the vendor's image models so
  one can be picked while the provider is added.

Tests: TestResponsesOnlyProviderDraws, TestListOffersImageModels.

* fix: route Codex native images through its turn provider

---------

Co-authored-by: yetone <yetoneful@gmail.com>
2026-10-05 17:19:42 +08:00