crewai - ✅(Solved) Fix Regression: PR #4656 fix broken in v1.11.1 - Tool error handling and name collision resolution [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
crewAIInc/crewAI#5244Fetched 2026-04-08 02:43:14
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
closed ×1commented ×1cross-referenced ×1referenced ×1

A regression was introduced in version 1.11.1 that breaks the fix from PR #4656, which addressed tool error handling and name collision resolution.

Error Message

A regression was introduced in version 1.11.1 that breaks the fix from PR #4656, which addressed tool error handling and name collision resolution.

  • ✅ Fixed tool error handling by injecting errors as observations
  • ✅ Tool error handling working correctly
  1. Error handling consistency: Without consistent tool name extraction, the mapping between sanitized names and original tools fails

Root Cause

The _extract_tool_name() method was removed in commit bb9bcd6 as part of a cleanup effort to remove "unused" methods. However, this method was part of the PR #4656 fix for:

  1. Tool name collision resolution: The _tool_name_mapping dictionary relies on proper tool name extraction
  2. Error handling consistency: Without consistent tool name extraction, the mapping between sanitized names and original tools fails
  3. Feature support: This breaks features like result_as_answer, usage limits, and caching for tools with duplicate names

Fix Action

Fixed

PR fix notes

PR #5245: fix: wire _extract_tool_name into codebase and add regression tests for #5244

Description (problem / solution / changelog)

Summary

Addresses issue #5244 by ensuring _extract_tool_name() and check_native_todo_completion() (restored in #5243) cannot be silently removed as "dead code" again. The key changes:

Production code (agent_executor.py):

  • New _resolve_original_tool() method — centralizes the duplicated tool-lookup logic (check _tool_name_mapping first, fall back to scanning original_tools) that was previously copy-pasted in two places.
  • _should_parallelize_native_tool_calls() now routes through _extract_tool_name() instead of the standalone extract_tool_call_info(). This is the critical wiring that makes _extract_tool_name a live call site rather than dead code.
  • _execute_single_native_tool_call() now calls _resolve_original_tool() instead of repeating the 10-line inline lookup, reducing duplication.

Tests (test_agent_executor.py): 20 new regression tests across 5 classes:

  • TestExtractToolName — all provider formats (OpenAI, Gemini, Anthropic, dict, unknown)
  • TestToolNameCollisionResolutionconvert_tools_to_openai_schema deduplication
  • TestResolveOriginalTool — mapping lookup, fallback, collision-renamed, unknown
  • TestToolErrorHandlingRegression — error injection, result_as_answer, max_usage_count with renamed tools
  • TestShouldParallelizeUsesExtractToolName — verifies _extract_tool_name is called and result_as_answer blocks parallelization

Review & Testing Checklist for Human

  • Behavioral equivalence of the _should_parallelize refactor: the old code used extract_tool_call_info() which returns (id, name, args) or None; the new code uses _extract_tool_name() which returns the name or "unknown". Verify these are equivalent for the parallelization decision (only the name was used before).
  • _resolve_original_tool edge cases: uses getattr(self, "_tool_name_mapping", None) defensively. Confirm this is safe across all code paths where the method might be called before _setup_native_tools() populates the mapping.
  • Manual smoke test: create a crew with two tools that have identical names (e.g., two "Search" tools) and verify that both tools execute correctly via native tool calling, collision suffixes are applied, and result_as_answer / max_usage_count work on the renamed variants.

Notes

  • All 20 new tests pass locally alongside the existing 79 tests in the file (99 total).
  • The uv.lock on main has a parse error (missing version field at line 1126); this is a pre-existing issue unrelated to this PR. Tests were run after regenerating the lock locally.

Link to Devin session: https://app.devin.ai/sessions/99afc2d07f9743aebb44a9c547f8db25

<!-- CURSOR_SUMMARY -->

[!NOTE] Medium Risk Touches native tool execution/parallelization decisions and tool lookup, which can affect runtime behavior for function-calling providers and collision-renamed tools; mitigated by extensive new regression tests.

Overview Fixes native tool-call handling to avoid tool-name collisions and "unknown" name ambiguity by adding _resolve_original_tool() (centralized lookup via _tool_name_mapping with fallback), wiring _should_parallelize_native_tool_calls() through _extract_tool_name(), and updating _extract_tool_name() to return None for unrecognized formats.

Adds a large regression test suite covering tool-name extraction across provider formats, collision deduplication in convert_tools_to_openai_schema, original-tool resolution, native-tool error handling/usage limits/result-as-answer with collision-renamed tools, and ensuring parallelization logic calls _extract_tool_name().

<sup>Written by Cursor Bugbot for commit e40b29b5f5a0b469b730f55268c0a5ca01621c3c. This will update automatically on new commits. Configure here.</sup>

<!-- /CURSOR_SUMMARY -->

Changed files

  • lib/crewai/src/crewai/experimental/agent_executor.py (modified, +38/-32)
  • lib/crewai/tests/agents/test_agent_executor.py (modified, +528/-0)
RAW_BUFFERClick to expand / collapse

Description

A regression was introduced in version 1.11.1 that breaks the fix from PR #4656, which addressed tool error handling and name collision resolution.

Timeline

PR #4656 (Merged March 1, 2026 - Commit 1ac5801)

  • ✅ Fixed tool error handling by injecting errors as observations
  • ✅ Added _tool_name_mapping dictionary for name collision resolution
  • ✅ Added _extract_tool_name() method for extracting tool names

Version 1.10.1 (Released March 4, 2025)

  • ✅ Included PR #4656 fix (bug fix #9: "Inject tool errors as observations and resolve name collisions")
  • ✅ Tool error handling working correctly
  • ✅ Name collision resolution working correctly

Commit bb9bcd6 (March 30, 2026)

  • ❌ Removed _extract_tool_name() method as "unused"
  • ❌ Removed check_native_todo_completion() method as "unused"
  • This was a cleanup/refactoring commit that removed 31 lines from agent_executor.py

Version 1.11.1 (Released March 23, 2025)

  • ❌ Includes commit bb9bcd6 which removed critical code
  • ❌ Tool name extraction logic potentially broken
  • ❌ Name collision resolution potentially broken

Root Cause

The _extract_tool_name() method was removed in commit bb9bcd6 as part of a cleanup effort to remove "unused" methods. However, this method was part of the PR #4656 fix for:

  1. Tool name collision resolution: The _tool_name_mapping dictionary relies on proper tool name extraction
  2. Error handling consistency: Without consistent tool name extraction, the mapping between sanitized names and original tools fails
  3. Feature support: This breaks features like result_as_answer, usage limits, and caching for tools with duplicate names

Impact

  • Tools with duplicate names may not be correctly distinguished
  • Tool execution errors may not be properly captured as observations
  • Features that depend on tool name mapping may malfunction

Suggested Fix

  1. Option 1: Restore the _extract_tool_name() method from commit 1ac5801
  2. Option 2: Ensure extract_tool_call_info() properly handles all cases that _extract_tool_name() handled
  3. Option 3: Verify that _tool_name_mapping is still being populated and used correctly without the removed method
  4. Add regression tests to prevent this from breaking again

References

  • Original fix: #4656
  • Regression commit: bb9bcd6
  • Affected file: lib/crewai/src/crewai/experimental/agent_executor.py

Versions Affected

  • ✅ v1.10.1: Working
  • ❌ v1.11.1: Broken
  • ❌ v1.12.x+: Likely still broken (needs verification)

extent analysis

TL;DR

Restoring the _extract_tool_name() method or ensuring its functionality is replaced is likely necessary to fix the regression introduced in version 1.11.1.

Guidance

  • Review commit 1ac5801 to understand the original implementation of _extract_tool_name() and consider restoring it as a direct fix.
  • Evaluate extract_tool_call_info() to determine if it can be modified to handle all cases that _extract_tool_name() previously covered, ensuring no functionality gap.
  • Verify that _tool_name_mapping is correctly populated and utilized in the current version to identify any potential issues with tool name collision resolution.
  • Develop comprehensive regression tests to prevent similar regressions in the future, focusing on tool error handling and name collision resolution.

Example

# Example of how _extract_tool_name() might have been implemented
def _extract_tool_name(tool_info):
    # Logic to extract the tool name from tool_info
    # This is a placeholder and should be replaced with the actual logic from commit 1ac5801
    return tool_info.get('name')

Notes

The actual implementation of _extract_tool_name() is crucial for a precise fix. Without the exact code, any replacement or restoration should be carefully tested to ensure it covers all necessary cases.

Recommendation

Apply workaround by restoring the _extract_tool_name() method from commit 1ac5801 as it directly addresses the removed functionality, ensuring that tool name extraction and collision resolution are properly handled.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING