Commit Graph
2 Commits
Author SHA1 Message Date
yetone ea3d1c62e7 gateway, codexcat: Codex's image detail "original" goes as "high" to a relay's Responses API, and only DeepSeek's own API is told it takes it (qiu_eth)
qiu_eth on Discord, v0.1.2885: the Codex App on
opencode-go/deepseek-v4.1-flash got 400 "invalid image detail" / "this
feature is not yet supported by atlas" for every screenshot.

Where the values come from:
- input_modalities ["text","image"]: models.dev lists
  deepseek-v4.1-flash under opencode-go with input text and image, and
  841326709 (v0.1.2343) counts Go's media types as images. Go's own list
  says the same, so this stays.
- supports_image_detail_original true: codexcat set it on every model
  named deepseek-* on any provider (8acb0d3a7), copied from DeepSeek's
  own Codex setup for api.deepseek.com. A vendor rule had not been scoped
  to the vendor. Go serves this model on its Responses API (no npm in
  models.dev, so every API is open, 7c4a5d114), and Responses to
  Responses went as it came, so "original" reached Go and was refused.

The fix has two parts:
- codexcat sets supports_image_detail_original only for a model of
  DeepSeek's own provider (deepseek/…). The rest of DeepSeek's setup
  (shell_command, verbosity, summary, agents v2) still applies to every
  DeepSeek model.
- The gateway sends an input_image's detail "original" as "high" to any
  Responses API but OpenAI's (api.openai.com, chatgpt.com, Azure),
  DeepSeek's (api.deepseek.com) and a remote magpie, which decides for
  its own upstream. That covers the class: a Codex that already has the
  old catalog, a relay's GPT, and any other model whose catalog says
  original. Chat already did this (chatDetail). A body without "original"
  isn't parsed.

Checked against the class: other opencode-go models with images (Kimi,
GLM, MiniMax, Qwen) never had the flag, since it was DeepSeek-only, but
the gateway now covers them too. Nothing after v0.1.2885 had changed
this.

Run on mote (mote-run):
- go test ./internal/gateway ./internal/codexcat ./internal/catalog
  -count=1 -timeout 45m: all three ok (gateway 847s).
- gofmt -l: clean. GOOS=linux and GOOS=windows go vet of both packages: ok.

Broken by hand:
- With the gateway's rewrite turned off, TestOriginalDetailHighOnARelay
  is red: details ["original" "low" "original"], want ["high" "low"
  "high"].
- With codexcat back to `e.DetailOriginal = m.Images`,
  TestCodexCatalogDeepSeekAsDeepSeekSays is red:
  opencode-go/deepseek-v4.1-flash has supports_image_detail_original
  true.

Not tried: a real OpenCode Go request. The only Go key here answers 401
api_key_expired, so Go's 400 is the reporter's word, not reproduced,
and that Go takes "high" rests on the Responses spec, not on a run.
2026-11-05 11:45:44 +08:00
yetone 8acb0d3a7d codexcat: a DeepSeek model's Codex entry says what DeepSeek's own Codex setup says
Rollkey8 on X found DeepSeek in Codex through magpie duller than
DeepSeek's DSH. A real Codex 0.165.0 -> magpie -> api.deepseek.com
recording lost nothing in translation; what differed was the catalog
entry magpie writes for the model. DeepSeek's own Codex setup
(cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh) writes a
models.json for deepseek-flash and deepseek-v4-pro, and a DeepSeek
model's entry now takes its non-prompt fields from it:

- shell_type "shell_command" (Codex 0.165 reads it as unified_exec, its
  only shell tool, per openai_models.rs's serde alias; a Codex before
  that had a one-shot shell_command tool, which is what DeepSeek picks)
- support_verbosity true, default_verbosity "low" (text.verbosity low
  is sent)
- default_reasoning_summary "none": reasoning.summary "auto" is no
  longer sent; DeepSeek streams its reasoning as text
- multi_agent_version "v2" where magpie had none
- supports_image_detail_original on a model whose entry takes images

A DeepSeek model is deepseek-v4*/-flash/-pro/-chat/-reasoner after any
provider or relay prefix (codexcat.deepSeek); a routing group or an
R1-distill isn't one. Every other vendor's entry is unchanged.
default_reasoning_summary is tagged keep:"unset", so a value the user
put by hand in another model's entry stays through Keep, as it did
before magpie wrote the key anywhere.

Not taken, and why:
- base_instructions / model_messages: magpie never rewrites a model's
  Codex prompt (owner's rule).
- auto_compact_token_limit null: magpie's 272K Long conversations
  default came from a DeepSeek-flash latency report (e950eb080, ~550K
  turns waited 70-90s for a first token); Full window, or the model's
  Compact at, gives the whole 1M, and a model_auto_compact_token_limit
  the user set still comes first.
- supports_search_tool false on v4-pro: kept true for #258.
- reasoning levels: the provider's, as for every model.
- comp_hash, max_context_window (same as the window), web_search
  (config.toml, not the catalog).
- v4-pro's images: DeepSeek's pricing page, its live /models and
  models.dev all say text only, and magpie's own entry (/v1/models)
  says text. Codex's catalog lists it with image only when Settings ›
  Vision describes images for text-only models (codexListed's
  described()), by design.

Also adds the agent-wiring.md row "Codex: DeepSeek models".

What was run, at this tree (as daf576653, the same tree before the
gofmt commit was split out under it):
- TestCodexCatalogDeepSeekAsDeepSeekSays and
  TestCodexCatalogKeepsUsersSummary: red on the old codexcat.go (both
  FAIL with it stashed), green on the new.
- go test ./internal/codexcat ./internal/provider -run 'Codex|DeepSeek'
  on mote: ok.
- gofmt -l: clean. On mote: go vet ./..., GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./..., go build, GOOS=linux go
  build -tags nogui, GOOS=windows go build: all ok.
- Full suite on mote, go test -count=1 -timeout 45m ./..., alone on
  the box: 79 packages ok; internal/gui red only in its 10 real-window
  AppKit tests, each killed at its deadline, which is #4125 (mote's
  AppKit hang; recorded there).
- Real use: Codex 0.165.0 in a sandbox HOME against a magpie built
  from this tree with the owner's DeepSeek provider copied in (deleted
  after). The written catalog has shell_command for both models. A
  multi-step task on deepseek-v4-pro (write a module and unittest file,
  run the tests, fix, report) ran to the end, tests pass. Through a
  recording proxy the requests carry text.verbosity "low", reasoning
  {effort: high} with no summary, and the same tools as before
  (exec_command, write_stdin, apply_patch, ...).

Not tried: a Codex older than 0.165, where shell_command is a tool of
its own; deepseek-flash in a real run (only v4-pro); a blind side by
side against DSH on answer quality.
2026-10-30 18:44:23 +08:00