# Agent wont respond

**URL:** <https://discuss.huggingface.co/t/agent-wont-respond/142128>\
**Category:** Beginners\
**Created:** [February 21, 2025, 2:58am UTC](https://discuss.huggingface.co/t/agent-wont-respond/142128 "2025-02-21T02:58:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![12GaugeMage](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/12gaugemage/32/41644_2.png) [@12GaugeMage](https://discuss.huggingface.co/u/12GaugeMage)\
**Post date:** [February 21, 2025, 2:58am UTC](https://discuss.huggingface.co/t/agent-wont-respond/142128/1 "2025-02-21T02:58:50Z")

</div>

The code provided in the course using the Qwen model build and runs fine, there are no log errors either. However when i attempt to chat with agent it never responds. The only advice given was to change the model…which I did but still no answer. Really want to proceed with the course but i cant till i can get this agent responding. Any help would be appreciated. Thank you

---

<div class="post-metadata">

**Author:** ![Shouryahere](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@Shouryahere](https://discuss.huggingface.co/u/Shouryahere)\
**Post date:** [February 21, 2025, 7:23am UTC](https://discuss.huggingface.co/t/agent-wont-respond/142128/2 "2025-02-21T07:23:41Z")

</div>

can you share your space if it’s public?

---

<div class="post-metadata">

**Author:** ![12GaugeMage](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/12gaugemage/32/41644_2.png) [@12GaugeMage](https://discuss.huggingface.co/u/12GaugeMage)\
**Post date:** [February 21, 2025, 5:10pm UTC](https://discuss.huggingface.co/t/agent-wont-respond/142128/3 "2025-02-21T17:10:22Z")

</div>

Hello, i made the space public now. I’m unsure how to share it but maybe you can see it now that its public. Thank you for the help

---

<div class="post-metadata">

**Author:** ![testItBetter](https://avatars.discourse-cdn.com/v4/letter/t/b2d939/32.png) [@testItBetter](https://discuss.huggingface.co/u/testItBetter)\
**Post date:** [February 27, 2025, 9:52am UTC](https://discuss.huggingface.co/t/agent-wont-respond/142128/4 "2025-02-27T09:52:00Z")

</div>

**Hi @12GaugeMage,**

I’m also facing the same issue. Based on your agent’s weblink [here](https://huggingface.co/spaces/12GaugeMage/First_agent_template), I checked the logs (you can view them by clicking the “Logs” button on the webpage where your space is running). The logs indicate the following error:

```auto
Error in generating model output:
401 Client Error: Unauthorized for url: 
https://router.huggingface.co/hf-inference/models/Qwen/Qwen2.5-Coder-32B-Instruc
t/v1/chat/completions (Request ID: 
Root=1-67c03071-27d09e05777ee5be59165163;7c1a7376-6f61-4430-8dc4-e93100cb7646)

Invalid username or password.

```

This suggests an authentication issue when trying to access the Hugging Face inference API for the Qwen model. Additionally, the traceback error at:

```auto
total_input_tokens += agent.model.last_input_token_count
TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'

```

indicates that `last_input_token_count` might be returning `None`, which is causing the agent to fail.

I noticed that a commit has already been made addressing this issue [here](https://huggingface.co/spaces/agents-course/First_agent_template/commit/ae7a4944c6d5660f2caab0c947c20c3d1059b749). To resolve the problem, try updating the `model_id` in your code as follows:

```python
model_id = 'https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'

```

This should fix the issue and allow your agent to respond. Let me know if you need any further help!

---

<div class="post-metadata">

**Author:** ![12GaugeMage](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/12gaugemage/32/41644_2.png) [@12GaugeMage](https://discuss.huggingface.co/u/12GaugeMage)\
**Post date:** [February 27, 2025, 9:46pm UTC](https://discuss.huggingface.co/t/agent-wont-respond/142128/5 "2025-02-27T21:46:29Z")

</div>

Thank you! It worked. I appreciate the help 🙂

---

<div class="post-metadata">

**Author:** ![clinteroni](https://avatars.discourse-cdn.com/v4/letter/c/58f4c7/32.png) [@clinteroni](https://discuss.huggingface.co/u/clinteroni)\
**Post date:** [April 10, 2025, 3:08pm UTC](https://discuss.huggingface.co/t/agent-wont-respond/142128/6 "2025-04-10T15:08:22Z")

</div>

This gets me

`Bad request:`  
`Bad Request: Invalid state`

---

<div class="post-metadata">

**Author:** ![banto78](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/banto78/32/46037_2.png) [@banto78](https://discuss.huggingface.co/u/banto78)\
**Post date:** [April 26, 2025, 12:33pm UTC](https://discuss.huggingface.co/t/agent-wont-respond/142128/7 "2025-04-26T12:33:58Z")

</div>

Same error here, when I send any message in the chat I get error
