Skip to content

[BUG] Wrong role type added to messages array for AgentAction #1437

@shankinson

Description

@shankinson

Description

When the answer is an AgentAction, the message being appended to the messages array is set with role user. Since an AgentAction is a response from the AI/LLM, it should have the assistant role.

Steps to Reproduce

  1. Allow an agent to run a tool
  2. Inspect the messages sent to the LLM
  3. Notice the Thought: xxx, Action: xxx, Action Input: xxx, Observation: xxx message is a user message instead of an assistant message.

Expected behavior

The AgentAction should be added to the messages list as an assistant message instead of a user message.

Screenshots/Code snippets

image image The third message should be tagged as assistant since it is the LLM thinking and choosing the tool to use.

Operating System

macOS Sonoma

Python Version

3.10

crewAI Version

0.67.1

crewAI Tools Version

0.12.1

Virtual Environment

Conda

Evidence

image The third message should be role `assistant`

Possible Solution

Change user to assistant on line 154 of crew_agent_executor.py. I will be opening a PR for this.

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions