mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-16 12:28:30 +00:00
Fixes #3873 This commit addresses a bug where internal ReAct-style fields like 'Thought:', 'Action:', 'Action Input:', and 'Observation:' were leaking into the final agent output, particularly in hierarchical crews when delegated tasks failed or when agents hit max iterations. Changes: - Added sanitize_react_output() utility function to strip internal ReAct fields - Applied sanitization in handle_max_iterations_exceeded() when converting AgentAction to AgentFinish - Applied sanitization in format_answer() exception handling to prevent leaks when LLM responses cannot be parsed - Added comprehensive unit tests to verify the fix and prevent regressions - Updated pyproject.toml to use pytest-vcr instead of pytest-recording to resolve plugin conflicts The sanitization function removes lines starting with ReAct field markers while preserving legitimate content, ensuring clean user-facing outputs. Co-Authored-By: João <joao@crewai.com>