Skip to content

fix: propagate implicit @CrewBase names to crew events#5574

Merged
renatonitta merged 3 commits intomainfrom
rn/con-109-fix-crew-display-name-in-traces-logs
Apr 21, 2026
Merged

fix: propagate implicit @CrewBase names to crew events#5574
renatonitta merged 3 commits intomainfrom
rn/con-109-fix-crew-display-name-in-traces-logs

Conversation

@renatonitta
Copy link
Copy Markdown
Contributor

@renatonitta renatonitta commented Apr 21, 2026

Summary

Fixes the case where OpenTelemetry logs and traces report the crew or automation name as "crew" instead of the actual @CrewBase automation name.

  • propagate the @CrewBase class name onto the returned Crew instance only when name was not explicitly provided
  • preserve explicit Crew(name=...) values
  • avoid changing global Crew.name semantics or adding new Crew state just for tracing

Root Cause

For @CrewBase projects, the @crew factory could return a Crew instance that still had the default name "crew". That value was then emitted through kickoff events and consumed downstream by tracing/logging, causing OTel metadata to show the wrong automation name.

Changes

  • update the @crew decorator to apply the @CrewBase class name only when name was implicit
  • leave explicit Crew(name=...) untouched
  • add focused tests covering:
    • implicit class-name propagation
    • explicit-name preservation
    • kickoff events emitting the correct display name

Note

Low Risk
Low risk: narrowly changes @crew decorator behavior to set Crew.name only when the name was implicit, and adds tests to prevent regressions in event/tracing display names.

Overview
Fixes incorrect crew display names (e.g., defaulting to "crew") for @CrewBase projects by having the @crew decorator copy the @CrewBase class name onto the returned Crew instance only when name was not explicitly set (checked via Crew.model_fields_set).

Adds focused tests ensuring implicit class-name propagation, explicit Crew(name=...) preservation, and that CrewKickoffStartedEvent emits the expected display name for tracing/logging.

Reviewed by Cursor Bugbot for commit cd1c792. Bugbot is set up for automated code reviews on this repo. Configure here.

@linear
Copy link
Copy Markdown

linear Bot commented Apr 21, 2026

@renatonitta renatonitta self-assigned this Apr 21, 2026
Comment thread lib/crewai/tests/test_crew.py Fixed
@renatonitta renatonitta requested a review from lorenzejay April 21, 2026 16:58
@renatonitta renatonitta merged commit 42d6c03 into main Apr 21, 2026
54 checks passed
@renatonitta renatonitta deleted the rn/con-109-fix-crew-display-name-in-traces-logs branch April 21, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants