`trust_remote_code=True` is hard-coded in the Hugging Face and vLLM wrappers and cannot be turned off

オープン
#389 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@ningyixi がすでに取り組んでいます。

2026年11月30日 から。

  • #390 @ningyixi による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
50/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
huggingface, python

調査の方向性

The hard-coded trust_remote_code=True sits in lagent/llms/huggingface.py (tokenizer and model from_pretrained calls), lagent/llms/vllm_wrapper.py (LLM(...) and AsyncEngineArgs(...)), and lagent/actions/web_visitor.py (tokenizer load). Start by reading how model_kwargs and tokenizer_kwargs are merged into those calls, since that is where the duplicate-keyword TypeError comes from. Done means both parameters are exposed on the four classes and forwarded to every call, and the default stays True. The design of the parameter names and defaults should be confirmed with maintainers first.

索引モデルが issue の本文から書いたものです。

説明

The local model wrappers always pass trust_remote_code=True, with no way for the caller to disable it and no way to pin a Hub revision:

Why it matters

  • With trust_remote_code=True, Transformers and vLLM import and run the Python files shipped in the model repo. Because no revision is pinned, that code is whatever the Hub repo's default branch holds at load time, so an update or a compromised upstream repo runs new code in the agent process.
  • Callers cannot opt out: passing trust_remote_code=False in model_kwargs / tokenizer_kwargs raises TypeError: got multiple values for keyword argument 'trust_remote_code'. That makes the wrappers unusable in setups that require it to be off, even for models that do not need custom code.

I understand trust_remote_code was added on purpose (#49, #50) so that InternLM and Qwen checkpoints load out of the box, so this is not a request to remove it.

Suggested fix

  • Add trust_remote_code: bool = True (keeping today's default) and revision: Optional[str] = None parameters to HFTransformer, VllmModel, AsyncVllmModel and WebVisitor, and forward both to every from_pretrained / LLM(...) call instead of the hard-coded keyword.
  • Document that a commit hash for revision is recommended whenever trust_remote_code is on.

Found with lacan-scan v7.6.4 (rule AIS203), checked by hand.

主要言語
Python
スター
2.3k
フォーク
249
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

InternLM/lagent のほかの issue

InternLM/lagent の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。