Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Summary

Fixes #4186 - When LLMs output Action: None (or variations like Action: N/A, Action: no action), the parser now correctly treats this as a signal for a direct response instead of raising an OutputParserError.

Previously, the ReAct parser would fail when an LLM indicated it couldn't/shouldn't use a tool by outputting Action: None, causing the error handler to leak internal "Thought:" text to users.

Changes:

  • Added ACTION_NONE_REGEX constant to match non-action values (none, n/a, na, no action, no_action)
  • Updated parse() to detect Action: None patterns and convert them to AgentFinish
  • The thought content becomes the output, providing a clean response to users
  • Added 11 tests covering various formats

Review & Testing Checklist for Human

  • Verify regex doesn't match valid tool names: The pattern matches none|n/a|na|no action|no_action case-insensitively. Confirm no legitimate tools could be named this way.
  • Test with real LLM outputs: Run a crew with allow_delegation=True but no other agents to trigger the original issue scenario and verify the fix works end-to-end.
  • Review parenthesis handling logic (parser.py lines 130-134): The logic for stripping parentheses from patterns like Action: None (reason) has some complexity that may have edge cases.

Suggested test plan:

from crewai import Agent, Task, Crew

agent = Agent(
    role="Manager",
    goal="Help users",
    backstory="You coordinate tasks",
    allow_delegation=True
)

task = Task(
    description="Find information about XYZ integration",
    expected_output="Information about XYZ",
    agent=agent
)

crew = Crew(agents=[agent], tasks=[task])
result = crew.kickoff()
# Verify result doesn't contain "Thought:" prefix

Notes

When LLMs output 'Action: None' (or variations like 'Action: N/A'),
the parser now correctly treats this as a signal for a direct response
instead of raising an OutputParserError.

This fixes issue #4186 where the parser would fail and leak internal
'Thought:' text to users instead of providing a clean response.

Changes:
- Add ACTION_NONE_REGEX constant to match non-action values
- Update parse() to detect and handle Action: None patterns
- Convert Action: None to AgentFinish with the thought as output
- Add comprehensive tests for all variations

Closes #4186

Co-Authored-By: João <joao@crewai.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parser fails on 'Action: None' - LLM wants direct response but uses wrong format

1 participant