# Getting error everytime sending a task request

**URL:** <https://community.crewai.com/t/getting-error-everytime-sending-a-task-request/4864>\
**Category:** General\
**Created:** [March 21, 2025, 6:01am UTC](https://community.crewai.com/t/getting-error-everytime-sending-a-task-request/4864 "2025-03-21T06:01:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gurpreet](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/gurpreet/32/3136_2.png) [@gurpreet](https://community.crewai.com/u/gurpreet)\
**Post date:** [March 21, 2025, 6:01am UTC](https://community.crewai.com/t/getting-error-everytime-sending-a-task-request/4864/1 "2025-03-21T06:01:13Z")

</div>

I am using CrewAI to create an agent. Doing everything as mentioned in documentation. See below for the CrewBase class:

```
@CrewBase
class EnergyAssitt():
    """EnergyAssitt crew"""

    # Learn more about YAML configuration files here:
    # Agents: https://docs.crewai.com/concepts/agents#yaml-configuration-recommended
    # Tasks: https://docs.crewai.com/concepts/tasks#yaml-configuration-recommended
    agents_config = 'config/agents.yaml'
    tasks_config = 'config/tasks.yaml'

    def __init__ (self):
        logger.info(f" __init__")

    # If you would like to add tools to your agents, you can learn more about it here:
    # https://docs.crewai.com/concepts/agents#agent-tools
    @agent
    def assistant(self) -> Agent:
        logger.info(f"assistant")
        return Agent(
            config=self.agents_config['mechanical_assistant'],
            memory=True,
            memory_config=memory_config,
            verbose=True
        )

    # To learn more about structured task outputs,
    # task dependencies, and task callbacks, check out the documentation:
    # https://docs.crewai.com/concepts/tasks#overview-of-a-task
    @task
    def chat_task(self) -> Task:
        logger.info(f"chat_task")
        return Task(
            config=self.tasks_config['chat_task'],
            agent=self.assistant()
        )

    @crew
    def crew(self) -> Crew:
        """Creates the Energy Assisstant crew"""
        # To learn how to add knowledge sources to your crew, check out the documentation:
        # https://docs.crewai.com/concepts/knowledge#what-is-knowledge

        logger.info(f"crew")
        return Crew(
            agents=self.agents, # Automatically created by the @agent decorator
            tasks=self.tasks, # Automatically created by the @task decorator
            process=Process.sequential,
            knowledge_sources=[pdf_source],
            verbose=True,
            # process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/
        )

```

However, everytime I give a task request, I get following error:

```auto
`2025-03-19 16:46:10,270 - app.services.services - INFO - Task 5a3a8b3a-573f-4b18-9a11-43d079df87fb failed with error: 'mechanical_assistant'`

```

Any suggestions what is going wrong or how to troubleshoot.

---

<div class="post-metadata">

**Author:** ![zinyando](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/zinyando/32/4435_2.png) [@zinyando](https://community.crewai.com/u/zinyando)\
**Post date:** [March 21, 2025, 11:54am UTC](https://community.crewai.com/t/getting-error-everytime-sending-a-task-request/4864/2 "2025-03-21T11:54:17Z")

</div>

Are you sure `mechanical_assistant` agent is defined in `config/agents.yaml`?

Make sure the have the same casing. It might be helpful to past the definition of the agent in yaml, there might be something wrong there.

---

<div class="post-metadata">

**Author:** ![gurpreet](https://sea1.discourse-cdn.com/flex025/user_avatar/community.crewai.com/gurpreet/32/3136_2.png) [@gurpreet](https://community.crewai.com/u/gurpreet)\
**Post date:** [March 24, 2025, 4:34pm UTC](https://community.crewai.com/t/getting-error-everytime-sending-a-task-request/4864/3 "2025-03-24T16:34:35Z")

</div>

Thanx for suggestion. It worked.
