fix: OpenTelemetry logs and traces showing proper crew names#5564
fix: OpenTelemetry logs and traces showing proper crew names#5564renatonitta wants to merge 13 commits intomainfrom
Conversation
| return self | ||
|
|
||
| @property | ||
| def display_name(self) -> str: |
There was a problem hiding this comment.
Rather than adding new property logic, can we stick this in a @model_validator to keep from adding new attrs? Something like:
@model_validator(mode="after")
def _resolve_name(self) -> Self:
if self.name is None:
self.name = type(self).__name__
return self Then we can keep the same .name accessor throughout files.
The decorator would need to unconditionally assign the name like so:
crew_instance.name = getattr(self, "_crew_name", None) or crew_instance.name
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 6a41e6f. Configure here.
| # pollutes `model_fields_set`. | ||
| self._name_was_explicit = "name" in self.model_fields_set | ||
| if not self._name_was_explicit: | ||
| self.name = type(self).__name__ |
There was a problem hiding this comment.
Validator doesn't fallback when name is explicitly None
Low Severity
The _resolve_name validator uses "name" in self.model_fields_set to decide whether to apply the class-name fallback. When a user explicitly passes Crew(name=None), Pydantic includes "name" in model_fields_set, so _name_was_explicit becomes True and the fallback is skipped—leaving name as None. This breaks the "guaranteed non-None" invariant that downstream cast(str, self.name) calls rely on. The fallback condition needs to check self.name is None rather than not self._name_was_explicit, while keeping _name_was_explicit based on model_fields_set for the decorator's separate concern.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 6a41e6f. Configure here.
|
Closing this in favor of #5574 |


Summary
This PR fixes OpenTelemetry logs and traces showing
crew_name: "crew"for every unnamed automation, making it impossible to tell which automation ran. Root cause:Crew.namedefaulted to the literal string"crew", which propagated to every downstream event.The default is now
None, resolved at construction time via amodel_validatorthat falls back to the class name, matching Flow's existing pattern.Changes
Crew.namedefaults toNoneinstead of the literal"crew"._resolve_namemodel validator (mode="after") fills in the class name when no explicit name is provided.@crewdecorator propagates the@CrewBaseclass name to the returned Crew instance, preserving any explicitCrew(name=...)set inside the factory method.Behavior
Crew(name="My Automation", ...)crewMy Automationclass MyCrew(Crew)→MyCrew(...)crewMyCrew@CrewBase class ResearchCrew: @crew def crew(self):crewResearchCrewCrew(...)(bare, no name)crewCrewNote
Medium Risk
Changes
Crew.namedefaulting and propagation logic, which affects event payloads, memory scoping namespaces, and OpenTelemetry trace metadata for all crews. Risk is moderate due to behavior changes in identifiers that may impact downstream logging/metrics expectations.Overview
Unnamed
Crewinstances no longer default to the literal string"crew";Crew.namenow defaults toNoneand is resolved post-init to the concrete class name via a new_resolve_namemodel validator while tracking whether the user explicitly setname.Telemetry and UI surfaces now use this resolved name: kickoff/training/testing events emit the resolved
crew_name, checkpoint resume panels castcrew.nameas non-null, and the tracing listener treats missing/empty crew names as"Unknown Crew"instead of accepting falsy values.The
@crewfactory decorator now propagates the@CrewBaseclass name onto the returnedCrewinstance only whennamewas not explicitly provided, and tests were updated/added to lock in these naming semantics (plus a smalluv.locktimestamp change).Reviewed by Cursor Bugbot for commit 6a41e6f. Bugbot is set up for automated code reviews on this repo. Configure here.