crewai - ✅(Solved) Fix Add collision-resistant task run IDs across crew/flow executions [2 pull requests, 2 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#4607Fetched 2026-04-08 00:41:01
View on GitHub
Comments
2
Participants
2
Timeline
8
Reactions
0
Timeline (top)
commented ×2cross-referenced ×2referenced ×2closed ×1

Fix Action

Fixed

PR fix notes

PR #4608: Fix #4607: Add collision-resistant task run IDs across crew/flow executions

Description (problem / solution / changelog)

Fix #4607: Add collision-resistant task run IDs across crew/flow executions

Summary

Adds a new run_id property to Task that produces a collision-resistant identifier by combining the deterministic key (MD5 of description + expected_output) with the unique per-instance id (uuid4). This run_id is then emitted as task_run_id in all relevant telemetry spans.

The existing key property remains unchanged — it continues to serve as the structural/deterministic identifier used for crew composition and task copy/clone mapping.

Changes:

  • lib/crewai/src/crewai/task.py — new run_id property
  • lib/crewai/src/crewai/telemetry/utils.py — emit task_run_id in add_task_attributes
  • lib/crewai/src/crewai/telemetry/telemetry.py — include run_id in 4 task-data dictionaries (crew_creation shared, crew_creation non-shared, crew_execution_span, end_crew)
  • lib/crewai/tests/test_task.py — 6 new regression tests

Review & Testing Checklist for Human

  • Verify run_id adds value over existing task_id (uuid4): The task.id is already a unique uuid4 emitted as task_id in telemetry spans. Confirm that the new run_id (which is just md5(key|id)) provides meaningful additional value for downstream telemetry consumers vs. simply using task_id for correlation instead of task_key.
  • Confirm no downstream telemetry consumers need updating: This PR adds task_run_id to spans but does not change how telemetry records are correlated. If the overwrite problem was caused by something keying on task_key, that consumer also needs to change to use task_run_id or task_id.
  • No telemetry integration tests: Only Task-level unit tests were added. There are no tests verifying task_run_id actually appears in emitted telemetry spans. Consider whether this needs coverage.

Notes

Changed files

  • lib/crewai/src/crewai/task.py (modified, +15/-0)
  • lib/crewai/src/crewai/telemetry/telemetry.py (modified, +4/-0)
  • lib/crewai/src/crewai/telemetry/utils.py (modified, +1/-0)
  • lib/crewai/tests/test_task.py (modified, +101/-0)

PR #4609: Preserve full UUID entropy for executor instance IDs

Description (problem / solution / changelog)

Problem

AgentExecutor currently truncates UUIDs to 8 characters for _instance_id, which materially increases collision risk in concurrent/multi-run contexts.

Why now

Issue #4607 targets collision-resistant execution identifiers for task/crew/flow orchestration paths.

What changed

  • Updated AgentExecutor to retain full UUID string entropy for _instance_id.
  • Added regression coverage in lib/crewai/tests/agents/test_agent_executor.py to assert _instance_id is a full UUID.

Validation

  • cd lib/crewai && uv run pytest tests/agents/test_agent_executor.py -k 'executor_initialization or executor_instance_id_uses_full_uuid'

Refs #4607

Changed files

  • lib/crewai/src/crewai/experimental/agent_executor.py (modified, +2/-1)
  • lib/crewai/tests/agents/test_agent_executor.py (modified, +8/-0)
RAW_BUFFERClick to expand / collapse

Problem Task run IDs based on normalized task names can collide across crew/flow executions, risking telemetry overwrite and ambiguous audit correlation.

Why now High-volume multi-agent usage requires durable unique correlation IDs for task lifecycle tracing.

Expected behavior Task run identifiers are collision-resistant and preserve one-to-one mapping from execution to telemetry/events.

Acceptance criteria

  • Task run ID generation is collision-resistant.
  • Equivalent task-name fixtures across runs do not overwrite telemetry context.
  • Regression tests assert unique IDs and stable correlation fields.

Evidence packet

  • Commit under test: b371f97a2fa39e38c7613c1cb92348ae222f42fc
  • Runtime environment: macOS Darwin 25.3.0 arm64, Python 3.14.0
  • Minimal repro:
    1. Execute repeated crew/flow runs with same task names.
    2. Inspect emitted task-run IDs and telemetry records.
  • Expected: distinct run IDs with no overwrite.
  • Actual: name-derived strategy is collision-prone.

extent analysis

Fix Plan

To address the issue of collision-prone task run IDs, we will implement a UUID-based task run ID generation strategy.

Steps

  • Modify the task run ID generation logic to use a UUID library.
  • Ensure the UUID is generated for each task run, regardless of the task name.
  • Update the telemetry context to include the new UUID-based task run ID.

Example Code

import uuid

def generate_task_run_id(task_name):
    # Generate a UUID for each task run
    task_run_id = uuid.uuid4()
    return task_run_id

# Example usage:
task_name = "example_task"
task_run_id = generate_task_run_id(task_name)
print(task_run_id)

Verification

  • Execute repeated crew/flow runs with the same task names.
  • Inspect emitted task-run IDs and telemetry records to ensure they are distinct and do not overwrite each other.
  • Run regression tests to assert unique IDs and stable correlation fields.

Extra Tips

  • Consider using a distributed ID generator like Twitter Snowflake for high-volume usage.
  • Ensure the UUID library is properly configured and tested for uniqueness and performance.

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

crewai - ✅(Solved) Fix Add collision-resistant task run IDs across crew/flow executions [2 pull requests, 2 comments, 2 participants]