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

Abierto
#389 0 comentarios 0 reacciones 0 asignados Ver en GitHub

@ningyixi ya está trabajando en esto.

Desde el 30/11/2026.

  • #390 de @ningyixi — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
50/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
huggingface, python

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
2.3k
Forks
249
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de InternLM/lagent

Todos los issues de InternLM/lagent

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.