Repository navigation
Description
Summary
For named custom open-ai-compatible provider profiles, a model that does not declare an
input list is assumed to support image input. When a tool (e.g. read on an image file)
puts an image into conversation history, subsequent requests include image_url and
text-only endpoints reject them with HTTP 400.
The failure persists for as long as the config is unchanged: every following turn re-sends
the image from history, and /compact does not help, because the compaction request itself
carries the same image. There is no in-app way to drop the image. Recovery requires editing
the provider config to declare input and restarting jcode; after that the existing session
continues normally, because the image is stripped per request. The trigger is easy to hit
accidentally, since read accepts image paths.
Environment
- jcode v0.71.1, linux-x86_64
- Provider type:
open-ai-compatible, self-hosted internal gateway
Reproduction
Config:
[providers.my-gateway]
type = "open-ai-compatible"
base_url = "https://internal-gateway.example.com/v1"
default_model = "my-text-model"
[[providers.my-gateway.models]]
id = "my-text-model"- Start a session and ask the agent to
readan image file. - Send any follow-up message.
- Request fails:
status: 400 Bad Request
response: {"object":"error","message":"Model only supports text input; received unsupported
content type 'image_url'.","type":"BadRequestError","param":null,"code":400}
A/B verification
All runs on the same binary (v0.71.1) and the same two-turn flow
(turn 1: read an image; turn 2: send a trivial text message).
The only variable is the input key.
| Config | Turn 2 result |
|---|---|
input = ["text"] |
success |
input omitted |
400 Model only supports text input |
input = ["banana"] |
success |
input omitted, then /compact |
still 400 |
Every turn in the affected session keeps failing until input is declared in config and
jcode is restarted; the same session then works, since stripping is applied per request.
Cause
Two mechanisms combine.
1. Models without input are absent from the capability map.
static_image_input_support is populated only in new_named_openai_compatible
(crates/jcode-provider-openrouter-runtime/src/lib.rs:1324-1338), and models with an empty
input are skipped outright:
let id = model.id.trim();
if id.is_empty() || model.input.is_empty() {
return None;
}
let supports_images = model
.input
.iter()
.any(|input| input.eq_ignore_ascii_case("image"));
Some((id.to_ascii_lowercase(), supports_images))A model with no input gets no entry at all, so the lookup misses rather than returning
false.
2. The fallback then reports image support.
supports_image_input() in
crates/jcode-provider-openrouter-runtime/src/openrouter_provider_impl.rs:360-365
falls back to !self.supports_provider_features. For a named profile whose
provider_type is not OpenRouter and which sets neither provider_routing nor
allow_provider_pinning, supports_provider_features is false
(lib.rs:1348-1352), so the negation yields true and the image is not stripped.
This explains all three rows of the table: ["text"] and ["banana"] both create an entry
resolving to false and the image is stripped, while an omitted input skips the map and
hits the permissive fallback.
The bug does not depend on the model family, only on whether input is declared.
Note on the existing fallback
The fallback is deliberate and documented: the comment at
openrouter_provider_impl.rs:360-365 explains that direct openai-compatible local
providers such as Ollama and LM Studio document image support on
/v1/chat/completions, and that the legacy OpenRouter aggregator behaviour is
intentionally left unchanged.
That reasoning holds for those cases. The problem is that named custom profiles always
evaluate supports_provider_features to false, so they inherit the local-provider
assumption even when the endpoint is a plain text-only gateway.
Secondary finding: unknown input values are silently accepted
eq_ignore_ascii_case("image") at lib.rs:1335 is the only place a declared modality
string is compared against image. (route_builders.rs:62 matches image as a token in
model names, and catalog_routes.rs:502 compares input against text; neither
validates declared modalities.) Anything that is not image is treated as "no image
support" with no warning or config error, so input = ["banana"] silently behaves like
input = ["text"]. A typo in a modality name is therefore invisible, which made the
original bug harder to isolate.
Suggested fix
Preferred: for named custom openai-compatible profiles, default models with no declared
input to text-only, and make image support opt-in via input = ["text", "image"]. This
fails safe. An endpoint that does support images merely degrades to placeholder text,
whereas the current default breaks every turn of the session until the user discovers the
config key. Local-provider and OpenRouter paths can keep their present behaviour, since
they do not populate this map.
Additionally: validate input entries against a known modality allowlist and raise a
config error on unknown values.
If reversing the default is considered too breaking, an alternative is to classify this 400
as an image-capability error and retry once with images stripped, caching the result for
the rest of the session.
I am happy to open a PR once you indicate which direction you prefer, since changing the
default is potentially breaking for users who rely on the current implicit behaviour.
Activity
[-]Unknown models on custom openai-compatible providers are assumed to support image input, breaking sessions unrecoverably[/-][+]Named custom openai-compatible models without `input` are assumed to support images[/+]1jehuang commentedon Aug 9, 2026
Confirmed. Named OpenAI-compatible models with an omitted
inputlist currently miss a capability entry and then fall through to an image-capable default. I am preparing a focused text-only default fix while preserving explicit image support, with regression tests.--- — Jcode agent (automated triage), on behalf of @1jehuang
1jehuang commentedon Aug 9, 2026
The verified fix is now in PR #856. Focused regressions passed, and the combined TUI build completed successfully.
--- — Jcode agent (automated triage), on behalf of @1jehuang
fix: default custom model input to text only (fixes 1jehuang#847)
chore: sync fork with upstream jcode (fresh merge onto current master) (
fix: default custom model input to text only (fixes 1jehuang#847)
fix: default custom model input to text only (fixes 1jehuang#847)
fix: default custom model input to text only (fixes 1jehuang#847)
fix: default custom model input to text only (fixes 1jehuang#847)
fix: default custom model input to text only (fixes 1jehuang#847)
fix: default custom model input to text only (fixes 1jehuang#847)
fix: default custom model input to text only (fixes 1jehuang#847)