{"slug": "hf-agents-course-error-in-duplicating-my-first-agent", "title": "HF agents course error in duplicating my first agent", "summary": "A Hugging Face agents course user encountered a runtime error when duplicating the first agent example on ZeroGPU, with the message 'No @spaces.GPU function detected during startup.' The fix involves adding an unused @spaces.GPU-decorated dummy function to app.py, adding a final_answer section to prompts.yaml, and recreating the HF_TOKEN secret, as ZeroGPU requires the decorator even though the LLM inference runs via Inference Providers, not on the Space GPU.", "body_md": "i tried to duplicate the agents example using zeroGPU cz it’s the free one , but i get this error runtime error\n\nHmm… at first I thought, “Why ZeroGPU??” …but apparently with a Free account now, ZeroGPU is basically the only compute-backed Gradio option you can host yourself… I didn’t know that.\n\nThe immediate error:\n\n```\nNo @spaces.GPU function detected during startup\n```\n\ndoes not look like a `smolagents`\n\nor Qwen error. It is ZeroGPU rejecting the Space at startup because it cannot find a function decorated with `@spaces.GPU`\n\n.\n\nFor **this particular course template**, I would take the minimal route first rather than trying to move the agent itself onto the GPU.\n\nAdd this near the imports in `app.py`\n\n:\n\n``` python\nimport spaces\n\n@spaces.GPU(duration=1)\ndef dummy_gpu():\n    return None\n```\n\nand leave the function unused.\n\nThe documented/intended ZeroGPU pattern is, of course, to decorate an actual GPU-dependent function; see the [ZeroGPU documentation](https://huggingface.co/docs/hub/spaces-zerogpu). The decorator causes a GPU to be allocated when the decorated function is called and released afterward.\n\nBut this course agent does **not actually need a Space GPU for its LLM inference**, so I tested the unused dummy-decorator variant in a duplicated ZeroGPU Space, and it was enough to get past this startup check.\n\nI would also make one tiny preventive edit to `prompts.yaml`\n\nwhile you are there:\n\n```\n\"final_answer\":\n  \"pre_messages\": \"\"\n  \"post_messages\": \"\"\n```\n\nAdd that as a top-level section near the end of the file.\n\nAnd make sure that your duplicated Space has an `HF_TOKEN`\n\n**Secret** with inference permission. Secrets are deliberately not copied into duplicated Spaces; the [course itself asks you to recreate HF_TOKEN](https://huggingface.co/learn/agents-course/unit1/tutorial), and the\n\nFor the smallest-change course path, I would therefore do only this initially:\n\n```\n1. Keep the template's smolagents==1.13.0 for now.\n2. Add the unused @spaces.GPU dummy.\n3. Add the three-line final_answer section to prompts.yaml.\n4. Recreate/check HF_TOKEN.\n5. Rebuild.\n```\n\nI would **not** upgrade all of `smolagents`\n\nat the same time unless you actually want to modernize the template, because there is a separate version-drift problem hiding behind this one.\n\nThe important conceptual warning is that **getting the ZeroGPU Space to start does not mean that Qwen-32B is now running for free on ZeroGPU**. Those are two different systems.\n\n```\nZeroGPU\n    → hosts the Gradio Space / allocates GPU to @spaces.GPU calls\n\nInferenceClientModel\n    → calls a remotely hosted model through Hugging Face Inference Providers\n```\n\nThe [current course page](https://huggingface.co/learn/agents-course/unit1/tutorial) explicitly uses:\n\n```\nmodel = InferenceClientModel(\n    max_tokens=2096,\n    temperature=0.5,\n    model_id=\"Qwen/Qwen2.5-Coder-32B-Instruct\",\n    custom_role_conversions=None,\n)\n```\n\nand describes Qwen2.5-Coder-32B-Instruct as being accessed through the serverless API.\n\nSo there are really several independent traps layered on top of each other here.\n\nWhy choosing ZeroGPU on a Free account actually makes sense nowSo my mental model for this particular failure would be:\n\n```\nTrap 1:\nFree-account Space policy\n    ↓\nZeroGPU becomes the practical free Gradio-hosting route\n\nTrap 2:\nZeroGPU expects @spaces.GPU\n    ↓\nold course template has none\n    ↓\n\"No @spaces.GPU function detected\"\n\nTrap 3:\ngetting ZeroGPU to start does NOT put Qwen-32B on ZeroGPU\n    ↓\nthe LLM still uses Inference Providers\n    ↓\nseparate inference credits / provider limits apply\n\nTrap 4:\nthe current lesson and duplicate template have version drift\n    ↓\nHfApiModel vs InferenceClientModel\nsmolagents 1.13.0 pin\nmissing final_answer prompt\nother migration differences\n```\n\nFor **your immediate problem**, though, I would not try to solve all four layers at once.\n\nI would start with just:\n\n``` python\nimport spaces\n\n@spaces.GPU(duration=1)\ndef dummy_gpu():\n    return None\n```\n\nplus:\n\n```\n\"final_answer\":\n  \"pre_messages\": \"\"\n  \"post_messages\": \"\"\n```\n\nmake sure `HF_TOKEN`\n\nexists, and rebuild.\n\nIf that starts, then the original ZeroGPU error is solved. Any error after that is much easier to classify as an inference/token/provider issue or as the separate template-version issue above, rather than one giant mysterious Space failure.", "url": "https://wpnews.pro/news/hf-agents-course-error-in-duplicating-my-first-agent", "canonical_source": "https://discuss.huggingface.co/t/hf-agents-course-error-in-duplicating-my-first-agent/178636#post_2", "published_at": "2026-08-14 12:29:36+00:00", "updated_at": "2026-08-14 12:43:55.373668+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-tools", "developer-tools"], "entities": ["Hugging Face", "ZeroGPU", "smolagents", "Qwen2.5-Coder-32B-Instruct", "InferenceClientModel", "HF_TOKEN"], "alternates": {"html": "https://wpnews.pro/news/hf-agents-course-error-in-duplicating-my-first-agent", "markdown": "https://wpnews.pro/news/hf-agents-course-error-in-duplicating-my-first-agent.md", "text": "https://wpnews.pro/news/hf-agents-course-error-in-duplicating-my-first-agent.txt", "jsonld": "https://wpnews.pro/news/hf-agents-course-error-in-duplicating-my-first-agent.jsonld"}}