Open
Conversation
daf2f9f to
0804439
Compare
Evanev7
approved these changes
Feb 24, 2026
Member
Evanev7
left a comment
There was a problem hiding this comment.
twice is reaching refactor point but will do for now
Some custom models (e.g. Kimi) require trust_remote_code=True to load their tokenizers. This adds an opt-in CLI flag that sets an env var read by runner subprocesses, following the same pattern as --fast-synch. The flag is intentionally CLI-only (not API-accessible) to prevent remote code execution attacks via the API. Also changes the default TRUST_REMOTE_CODE constant from True to False, making remote code execution fully opt-in. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The constant is the default for built-in models with known model cards, which are trusted. Custom models added via API already default to trust_remote_code=False in ModelCard.fetch_from_hf(). The CLI flag overrides custom models only. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
d383b9a to
0dde45a
Compare
Evanev7
reviewed
Feb 24, 2026
| # TODO: We should really make this opt-in, but Kimi requires trust_remote_code=True | ||
| # True for built-in models with known model cards; custom models added via API default to False | ||
| # and can be overridden with the --trust-remote-code CLI flag. | ||
| TRUST_REMOTE_CODE: bool = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Some custom models (e.g. Kimi) require
trust_remote_code=Trueto load their tokenizers. Currently theTRUST_REMOTE_CODEconstant defaults toTrueglobally, which is a security risk. Users need an explicit opt-in mechanism that is only available via the CLI — not the API — to prevent remote code execution attacks.Changes
--trust-remote-codeCLI flag toArgsinsrc/exo/main.pyEXO_TRUST_REMOTE_CODE=1env var, inherited by runner subprocesses (same pattern as--fast-synch)get_tokenizer()inutils_mlx.pychecks the env var and overridestrust_remote_codetoTruewhen setTRUST_REMOTE_CODEconstant fromTruetoFalseinconstants.py, making remote code execution fully opt-inWhy It Works
The env-var approach follows the established
--fast-synchpattern: CLI sets the env var in the main process, runner subprocesses (spawned viamp.Process) inherit it. The override is applied at the single point wheretrust_remote_codeflows toload_tokenizer_for_model_id(). The flag is intentionally CLI-only — not exposed via the API — so remote attackers cannot enable it.Test Plan
Manual Testing
uv run exo --helpshows the new--trust-remote-codeflaguv run exo --trust-remote-codelogs a warning about arbitrary code execution/models/addload withtrust_remote_code=FalseAutomated Testing
uv run basedpyright— 0 errorsuv run ruff check— all checks passeduv run pytest— 222 passed (1 pre-existing failure in Rust bindings unrelated to this change)nix fmt— applied🤖 Generated with Claude Code