# AI agent unit 1 - run problem in the agent chat

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fai-agent-unit-1-run-problem-in-the-agent-chat%2F143752%3E%5C
**Category:** Course\
**Created:** [March 3, 2025, 4:11am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fai-agent-unit-1-run-problem-in-the-agent-chat%2F143752 "2025-03-03T04:11:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel159357](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@daniel159357](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdaniel159357)%5C
**Post date:** [March 3, 2025, 4:11am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fai-agent-unit-1-run-problem-in-the-agent-chat%2F143752%2F1 "2025-03-03T04:11:02Z")

</div>

![image](https://us1.discourse-cdn.com/hellohellohello/original/3X/6/2/62198b578bcf22102b02cb4ce1058ca57f59c40c.png)

I have copied to my space to try the AI agent but I encounter the below problems. Please help to solve this. Thanks.

===== Application Startup at 2025-03-03 02:06:07 =====

tool.py: 0%| | 0.00/635 [00:00\<?, ?B/s]  
tool.py: 100%|██████████| 635/635 [00:00\<00:00, 3.62MB/s]

- Running on local URL: [http://0.0.0.0:7860](http://0.0.0.0:7860), with SSR ⚡ (experimental, to disable set `ssr=False` in `launch()`)  
/usr/local/lib/python3.10/site-packages/gradio/blocks.py:2680: UserWarning: Setting share=True is not supported on Hugging Face Spaces  
warnings.warn(

To create a public link, set `share=True` in `launch()`.  
╭────────────────────────────────── New run ───────────────────────────────────╮  
│ │  
│ hello │  
│ │  
╰─ HfApiModel - Qwen/Qwen2.5-Coder-32B-Instruct ───────────────────────────────╯  
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Step 1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  
Error in generating model output:  
401 Client Error: Unauthorized for url:  
[/static-proxy?url=https%3A%2F%2Frouter.huggingface.co%2Fhf-inference%2Fmodels%2FQwen%2FQwen2.5-Coder-32B-Instruc%5D(https%3A%2F%2Frouter.huggingface.co%2Fhf-inference%2Fmodels%2FQwen%2FQwen2.5-Coder-32B-Instruc)  
t/v1/chat/completions (Request ID:  
Root=1-67c5103a-73922cc22c6652503fd16939;f22c21f3-384d-4e88-970f-fe21266989e4)

Invalid username or password.  
[Step 0: Duration 0.03 seconds]  
Traceback (most recent call last):  
File “/usr/local/lib/python3.10/site-packages/gradio/queueing.py”, line 715, in process\_events  
response = await route\_utils.call\_process\_api(  
File “/usr/local/lib/python3.10/site-packages/gradio/route\_utils.py”, line 322, in call\_process\_api  
output = await app.get\_blocks().process\_api(  
File “/usr/local/lib/python3.10/site-packages/gradio/blocks.py”, line 2088, in process\_api  
result = await self.call\_function(  
File “/usr/local/lib/python3.10/site-packages/gradio/blocks.py”, line 1647, in call\_function  
prediction = await utils.async\_iteration(iterator)  
File “/usr/local/lib/python3.10/site-packages/gradio/utils.py”, line 728, in async\_iteration  
return await anext(iterator)  
File “/usr/local/lib/python3.10/site-packages/gradio/utils.py”, line 722, in **anext**  
return await anyio.to\_thread.run\_sync(  
File “/usr/local/lib/python3.10/site-packages/anyio/to\_thread.py”, line 56, in run\_sync  
return await get\_async\_backend().run\_sync\_in\_worker\_thread(  
File “/usr/local/lib/python3.10/site-packages/anyio/\_backends/\_asyncio.py”, line 2461, in run\_sync\_in\_worker\_thread  
return await future  
File “/usr/local/lib/python3.10/site-packages/anyio/\_backends/\_asyncio.py”, line 962, in run  
result = context.run(func, \*args)  
File “/usr/local/lib/python3.10/site-packages/gradio/utils.py”, line 705, in run\_sync\_iterator\_async  
return next(iterator)  
File “/usr/local/lib/python3.10/site-packages/gradio/utils.py”, line 866, in gen\_wrapper  
response = next(iterator)  
File “/home/user/app/Gradio\_UI.py”, line 197, in interact\_with\_agent  
for msg in stream\_to\_gradio(self.agent, task=prompt, reset\_agent\_memory=False):  
File “/home/user/app/Gradio\_UI.py”, line 145, in stream\_to\_gradio  
total\_input\_tokens += agent.model.last\_input\_token\_count  
TypeError: unsupported operand type(s) for +=: ‘int’ and ‘NoneType’

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [March 3, 2025, 4:46pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fai-agent-unit-1-run-problem-in-the-agent-chat%2F143752%2F2 "2025-03-03T16:46:03Z")

</div>

From HF Discord:

> Worked for me by changing the model id to:  
> model\_id=‘[https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud/](https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud/)’

> you need to set your HF\_TOKEN in the spaces options under secret. Do not hard code them into your app.py… then anyone could look at your source code and use your token.

 ![token0](https://us1.discourse-cdn.com/hellohellohello/original/3X/d/a/da3f1ab248b5ba48afa4a0668b1112f837185ff0.png)  
 ![token](https://us1.discourse-cdn.com/hellohellohello/original/3X/e/8/e88dbf51760c586c8777be350d5a24a7753b2608.png)
