Skip to content

feat(crewai): Enable Tracing Support For CrewAI Flow Nodes#2780

Closed
ialisaleh wants to merge 13 commits intoArize-ai:mainfrom
ialisaleh:alisaleh/ticket-2751
Closed

feat(crewai): Enable Tracing Support For CrewAI Flow Nodes#2780
ialisaleh wants to merge 13 commits intoArize-ai:mainfrom
ialisaleh:alisaleh/ticket-2751

Conversation

@ialisaleh
Copy link
Copy Markdown
Collaborator

@ialisaleh ialisaleh commented Feb 23, 2026

Closes #2751

Example Trace

CrewAI_Flow_Nodes

Note

Medium Risk
Wraps an internal CrewAI method (Flow._execute_method) and changes span emission behavior, which may be sensitive to upstream CrewAI implementation changes and could affect tracing volume/structure.

Overview
Adds OpenInference tracing for individual CrewAI Flow nodes by instrumenting Flow._execute_method, creating per-step CHAIN spans named like <flow>.<method> with flow.node.name/flow.node.type attributes and captured outputs.

Updates tests to expect and validate these new node spans (including nested-flow scenarios), and refreshes example flows to provide explicit Task.name values, tweak plotting/output formatting, and include crewai-tools in example requirements.

Written by Cursor Bugbot for commit 721511b. This will update automatically on new commits. Configure here.

@ialisaleh ialisaleh marked this pull request as ready for review February 25, 2026 15:13
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 25, 2026
@ialisaleh ialisaleh requested a review from caroger February 26, 2026 15:07
@ialisaleh ialisaleh requested a review from a team as a code owner March 3, 2026 16:22
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@caroger
Copy link
Copy Markdown
Collaborator

caroger commented Mar 5, 2026

hey @ialisaleh , thanks for working on this

I opened PR #2848 which covers the same _FlowExecuteMethodWrapper addition and goes a bit further — wanted to flag a couple of differences before either moves forward.

Response unpacking: Flow._execute_method in crewAI 1.10.x returns a (result, next_method_name | None) tuple internally. Passing that directly to get_output_attributes serializes the whole tuple instead of just the node's return value. PR #2848 extracts response[0] when the response is a tuple to get the actual node result.

agent_kickoff_active guard: Agent.kickoff() internally spins up a Flow, which would cause _FlowExecuteMethodWrapper to emit node spans even for
standalone agent calls. PR #2848 uses an _agent_kickoff_active contextvar to suppress those.

Broader scope: PR #2848 also addresses the root context-propagation bug (spans from Flow→Crew ending up in separate traces) via _FlowKickoffWrapper creating the CHAIN span before asyncio.run(), and the TOOL span nesting bug via _ExecuteWithTimeoutWrapper.

@ialisaleh
Copy link
Copy Markdown
Collaborator Author

#2848 merged, so closing this PR.

@ialisaleh ialisaleh closed this Mar 9, 2026
@ialisaleh ialisaleh self-assigned this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[bug] Node_names are missing in traces for CrewAI autoinstrumentor

2 participants