Skip to content

fix(open-interpreter): model handle fixes — force openai wire, read $MODEL not $EVAL_MODEL - #354

Open
elronbandel wants to merge 2 commits into
mainfrom
elron/open-interpreter-model-fixes
Open

fix(open-interpreter): model handle fixes — force openai wire, read $MODEL not $EVAL_MODEL#354
elronbandel wants to merge 2 commits into
mainfrom
elron/open-interpreter-model-fixes

Conversation

@elronbandel

@elronbandel elronbandel commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Started as a combination of #339 (Doron Chen) with a $MODEL/$EVAL_MODEL fix.
While verifying it live against a capturing mock, found that #339's own fix
doesn't actually work for the exact case it targets — reworked accordingly.

#339 — don't double-prefix provider-scoped EVAL_MODEL (kept, cherry-picked)

interpreter.llm.model unconditionally prepended openai/, so a
provider-scoped handle (e.g. gcp/gemini-3.5-flash-lite) became malformed
(openai/gcp/gemini-3.5-flash-lite). Its fix added a "/" in model guard
copied from openhands/terminus-2's old pattern.

Found while verifying — the guard doesn't actually work

Live-tested with a provider-prefixed canary handle: the guard correctly
skips the openai/ prefix, but the unmodified handle then reaches
litellm.completion(), which tries to resolve gcp as a real litellm
provider name (it isn't — litellm's name for it is vertex_ai) and raises
BadRequestError: LLM Provider NOT provided. Reproduced the exact crash
#339 claims to prevent, using #339's own fix.

Root fix (same approach as #348/terminus-2): force the wire explicitly via
litellm's custom_llm_provider parameter, regardless of what the handle
carries. open-interpreter's Llm class has no dedicated field for this
(unlike harbor's LiteLLM wrapper), so it's done by wrapping
llm.completions (a plain function forwarding **params to
litellm.completion(**params)).

Also — read $MODEL not $EVAL_MODEL

run-agent's env -i allow-list forwards only MODEL to the agent
process — EVAL_MODEL is scrubbed away (same bug #320/#334 fixed in ten
other agents). run_oi.py read EVAL_MODEL directly with no
Dockerfile-level shim, so it always fell back to "default" regardless of
any guard logic.

Verification

Built the actual image and ran it against a request-capturing mock
(tests/run/gateways/mock_upstream.py) with distinctive canary model
handles:

  • Bare handle (verify-canary-bare-8x1) → reaches the wire unmodified, no crash.
  • Provider-prefixed handle (gcp/verify-canary-slash-4k9) → reaches the wire
    unmodified, no crash (previously crashed with BadRequestError under fix(open-interpreter): don't double-prefix provider-scoped EVAL_MODEL #339's
    own fix).
  • EVAL_MODEL set to a decoy value while MODEL carries the real one →
    confirmed MODEL wins, EVAL_MODEL is ignored.

Closes #339.

interpreter.llm.model unconditionally prepended "openai/", so an
EVAL_MODEL that already carries a routing prefix (e.g.
gcp/gemini-3.5-flash-lite) became malformed (openai/gcp/...). Guard
matches the pattern already used by terminus-2 and openhands.

Checked against: .agents/gateways/RULES.md rule 23 (EVAL_MODEL is a
bare, opaque handle that MAY already carry a provider prefix).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Doron Chen <cdoron@il.ibm.com>
…not $EVAL_MODEL

Two issues found while reviewing/verifying #339:

1. run-agent's env -i allow-list forwards only MODEL to the agent process —
   EVAL_MODEL is scrubbed away (same contract zerostack already follows,
   same bug #320/#334 fixed in ten other agents). run_oi.py read EVAL_MODEL
   directly with no Dockerfile-level shim, so it always fell back to the
   literal string "default" regardless of #339's guard fix.

2. #339's "/" guard (copied from openhands/terminus-2's old pattern) does
   not actually work for provider-scoped handles. Verified live: a handle
   like gcp/gemini-3.5-flash-lite skips the openai/ prefix (as intended)
   but then reaches litellm.completion() unmodified, and litellm tries to
   resolve "gcp" as a real provider name (it isn't — litellm's name for
   it is vertex_ai) and raises BadRequestError: LLM Provider NOT provided.
   Reproduced the exact crash #339 was supposed to prevent.

open-interpreter's Llm class has no field for litellm's custom_llm_provider
(unlike terminus-2/harbor's LiteLLM wrapper, see #348 — same underlying
issue, same fix approach). Fixed by wrapping llm.completions (a plain
function forwarding **params to litellm.completion(**params)) to inject
custom_llm_provider="openai" regardless of what the handle carries.

Verified live against a capturing mock: bare handle and provider-prefixed
handle (gcp/...) both now reach the wire unmodified, no crash, in both
cases before this fix would either mangle the model name (#339's original
bug) or crash outright (the case #339's own fix introduced).

Signed-off-by: Elron Bandel <elron.bandel@ibm.com>
@elronbandel
elronbandel force-pushed the elron/open-interpreter-model-fixes branch from 8d86dca to 87a0feb Compare August 12, 2026 14:01
@elronbandel elronbandel changed the title fix(open-interpreter): model handle fixes — double-prefix guard + $MODEL not $EVAL_MODEL fix(open-interpreter): model handle fixes — force openai wire, read $MODEL not $EVAL_MODEL Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants