Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
feat(events): record whether a run had inputs, without recording the inputs (#7072)
João Mouraf4731f5025f8
diff --git a/docs/edge/ar/telemetry.mdx b/docs/edge/ar/telemetry.mdxindex 6ea0f41af..3e04bddc2 100644--- a/docs/edge/ar/telemetry.mdx+++ b/docs/edge/ar/telemetry.mdx@@ -52,7 +52,7 @@ os.environ['OTEL_SDK_DISABLED'] = 'true'| افتراضي | البيانات | السبب والتفاصيل ||:----------|:------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------|| نعم | إصدار CrewAI وPython | تتبع إصدارات البرمجيات. مثال: CrewAI v1.2.3، Python 3.8.10. لا بيانات شخصية. |-| نعم | بيانات وصفية للطاقم | تشمل: مفتاح ومعرّف مُولّد عشوائياً، نوع العملية (مثل 'sequential'، 'parallel')، علم منطقي لاستخدام الذاكرة (true/false)، عدد المهام، عدد الوكلاء. كلها غير شخصية. |+| نعم | بيانات وصفية للطاقم | تشمل: مفتاح ومعرّف مُولّد عشوائياً، نوع العملية (مثل 'sequential'، 'parallel')، علم منطقي لاستخدام الذاكرة (true/false)، علم منطقي يوضح ما إذا تم تمرير أي مدخلات للتشغيل (true/false — وليس مفاتيح المدخلات أو قيمها، والتي لا تُجمع إلا عند تمكين `share_crew`)، عدد المهام، عدد الوكلاء. كلها غير شخصية. || نعم | بيانات الوكيل | تشمل: مفتاح ومعرّف مُولّد عشوائياً، اسم الدور (يجب ألا يتضمن معلومات شخصية)، إعدادات منطقية (verbose، التفويض مُفعّل، تنفيذ الكود مسموح)، أقصى عدد تكرارات، أقصى RPM، أقصى حد لإعادة المحاولة، معلومات LLM (انظر سمات LLM)، قائمة أسماء الأدوات (يجب ألا تتضمن معلومات شخصية). لا بيانات شخصية. || نعم | بيانات وصفية للمهمة | تشمل: مفتاح ومعرّف مُولّد عشوائياً، إعدادات تنفيذ منطقية (async_execution، human_input)، دور ومفتاح الوكيل المرتبط، قائمة أسماء الأدوات. كلها غير شخصية. || نعم | إحصائيات استخدام الأدوات | تشمل: اسم الأداة (يجب ألا يتضمن معلومات شخصية)، عدد محاولات الاستخدام (عدد صحيح)، سمات LLM المستخدمة. لا بيانات شخصية. |diff --git a/docs/edge/en/telemetry.mdx b/docs/edge/en/telemetry.mdxindex 0a6a285d9..b05dccf5d 100644--- a/docs/edge/en/telemetry.mdx+++ b/docs/edge/en/telemetry.mdx@@ -52,7 +52,7 @@ own tracer provider, which is independent of the one described here.| Defaulted | Data | Reason and Specifics ||:----------|:------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------|| Yes | CrewAI and Python Version | Tracks software versions. Example: CrewAI v1.2.3, Python 3.8.10. No personal data. |-| Yes | Crew Metadata | Includes: randomly generated key and ID, process type (e.g., 'sequential', 'parallel'), boolean flag for memory usage (true/false), count of tasks, count of agents. All non-personal. |+| Yes | Crew Metadata | Includes: randomly generated key and ID, process type (e.g., 'sequential', 'parallel'), boolean flag for memory usage (true/false), a boolean flag for whether any inputs were passed to the run (true/false — never the input keys or values, which are only collected when `share_crew` is enabled), count of tasks, count of agents. All non-personal. || Yes | Agent Data | Includes: randomly generated key and ID, role name (should not include personal info), boolean settings (verbose, delegation enabled, code execution allowed), max iterations, max RPM, max retry limit, LLM info (see LLM Attributes), list of tool names (should not include personal info). No personal data. || Yes | Task Metadata | Includes: randomly generated key and ID, boolean execution settings (async_execution, human_input), associated agent's role and key, list of tool names. All non-personal. || Yes | Tool Usage Statistics | Includes: tool name (should not include personal info), number of usage attempts (integer), LLM attributes used. No personal data. |diff --git a/docs/edge/ko/telemetry.mdx b/docs/edge/ko/telemetry.mdxindex 051c2b299..0c58f3fb4 100644--- a/docs/edge/ko/telemetry.mdx+++ b/docs/edge/ko/telemetry.mdx@@ -50,7 +50,7 @@ provider로 등록하지 않습니다. 이를 통해 양방향이 분리됩니| 기본값 | 데이터 | 사유 및 세부 사항 ||:--------|:-------------------------------------------|:----------------------------------------------------------------------------------------------------------------------|| 예 | CrewAI 및 Python 버전 | 소프트웨어 버전을 추적합니다. 예: CrewAI v1.2.3, Python 3.8.10. 개인 정보 없음. |-| 예 | Crew 메타데이터 | 랜덤으로 생성된 키 및 ID, 프로세스 유형(예: 'sequential', 'parallel'), 메모리 사용 플래그(boolean, true/false), 작업 수, 에이전트 수가 포함됩니다. 모두 비개인 정보입니다. |+| 예 | Crew 메타데이터 | 랜덤으로 생성된 키 및 ID, 프로세스 유형(예: 'sequential', 'parallel'), 메모리 사용 플래그(boolean, true/false), 실행에 입력이 전달되었는지를 나타내는 플래그(boolean, true/false — 입력 키나 값 자체는 포함되지 않으며, 이는 `share_crew`가 활성화된 경우에만 수집됩니다), 작업 수, 에이전트 수가 포함됩니다. 모두 비개인 정보입니다. || 예 | 에이전트 데이터 | 랜덤으로 생성된 키 및 ID, 역할 이름(개인 정보 포함 불가), boolean 설정(상세 출력, 위임 가능, 코드 실행 허용), 최대 반복 횟수, 최대 RPM, 최대 재시도 제한, LLM 정보(LLM 속성 참조), 도구 이름 목록(개인 정보 포함 불가) 포함. 개인 정보 없음. || 예 | 작업 메타데이터 | 랜덤으로 생성된 키 및 ID, boolean 실행 설정(async_execution, human_input), 관련 에이전트 역할 및 키, 도구 이름 목록이 포함됩니다. 모두 비개인 정보입니다. || 예 | 도구 사용 통계 | 도구 이름(개인 정보 포함 불가), 사용 시도 횟수(정수), 사용된 LLM 속성이 포함됩니다. 개인 정보 없음. |diff --git a/docs/edge/pt-BR/telemetry.mdx b/docs/edge/pt-BR/telemetry.mdxindex ee3335503..ce6129fa6 100644--- a/docs/edge/pt-BR/telemetry.mdx+++ b/docs/edge/pt-BR/telemetry.mdx@@ -52,7 +52,7 @@ por meio do próprio tracer provider, que é independente do descrito aqui.| Padrão | Dados | Razão e Especificidades ||--------|--------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|| Sim | Versão do CrewAI e Python | Rastreia versões dos softwares. Exemplo: CrewAI v1.2.3, Python 3.8.10. Sem dados pessoais. |-| Sim | Metadados do Crew | Inclui: chave e ID gerados aleatoriamente, tipo de processo (ex: 'sequential', 'parallel'), flag booleana para uso de memória (true/false), quantidade de tarefas, quantidade de agentes. Tudo não pessoal. |+| Sim | Metadados do Crew | Inclui: chave e ID gerados aleatoriamente, tipo de processo (ex: 'sequential', 'parallel'), flag booleana para uso de memória (true/false), uma flag booleana indicando se alguma entrada foi passada para a execução (true/false — nunca as chaves ou os valores das entradas, que só são coletados quando `share_crew` está habilitado), quantidade de tarefas, quantidade de agentes. Tudo não pessoal. || Sim | Dados do Agente | Inclui: chave e ID gerados aleatoriamente, nome da função (não deve incluir info pessoal), configurações booleanas (verbose, delegação habilitada, execução de código permitida), máximo de iterações, máximo de RPM, limite de tentativas, info do LLM (ver Atributos LLM), lista de nomes de ferramentas (não deve conter info pessoal). Sem dados pessoais. || Sim | Metadados da Tarefa | Inclui: chave e ID gerados aleatoriamente, configurações de execução booleanas (async_execution, human_input), função e chave do agente associado, lista de nomes de ferramentas. Tudo não pessoal. || Sim | Estatísticas de Uso de Ferramentas | Inclui: nome da ferramenta (não deve incluir info pessoal), número de tentativas de uso (inteiro), atributos LLM utilizados. Sem dados pessoais. |diff --git a/lib/crewai/src/crewai/telemetry/telemetry.py b/lib/crewai/src/crewai/telemetry/telemetry.pyindex 64ded3055..7412d642a 100644--- a/lib/crewai/src/crewai/telemetry/telemetry.py+++ b/lib/crewai/src/crewai/telemetry/telemetry.py@@ -310,6 +310,16 @@ class Telemetry:# rather than `is True`: memory counts as enabled when set by any means,# including a Memory/MemoryScope/MemorySlice instance.self._add_attribute(span, "crew_memory", "true" if crew.memory else "false")+ # A string for the same reason as `crew_memory` above, and the reason is+ # stronger here: the majority case is the empty one. Measured over a single+ # day (312,424,709 spans) not one carries vInt64='0' either, so an integer+ # key *count* would have dropped every unparameterised run - 54.46% of runs+ # among the opt-in sharers this was previously only measurable on.+ # Deliberately ungated: only whether inputs were passed travels, never the+ # payload, which stays inside the `share_crew` branch below (D13).+ self._add_attribute(+ span, "crew_inputs_present", "true" if inputs else "false"+ )self._add_attribute(span, "crew_number_of_tasks", len(crew.tasks))self._add_attribute(span, "crew_number_of_agents", len(crew.agents))diff --git a/lib/crewai/tests/telemetry/test_telemetry.py b/lib/crewai/tests/telemetry/test_telemetry.pyindex afc33a009..d1f2bd077 100644--- a/lib/crewai/tests/telemetry/test_telemetry.py+++ b/lib/crewai/tests/telemetry/test_telemetry.py@@ -403,6 +403,67 @@ def test_crew_memory_is_recorded_as_a_string(memory, expected: str) -> None:)+ ("inputs", "expected"),+ [+ ({"topic": "AI"}, "true"),+ ({"a": 1, "b": 2}, "true"),+ ({}, "false"),+ (None, "false"),+ ],+ ids=["one-key", "two-keys", "empty-dict", "none"],+)+def test_crew_inputs_presence_is_recorded_ungated_as_a_string(inputs, expected: str):+ """Whether a run was parameterised must be answerable for everyone, not just sharers.++ The `crew_inputs` payload is share_crew-gated and stays that way (D13), so the only+ signal in the warehouse was `has_crew_inputs`, derived from that gated key: 0 of+ 226,592 spans on 0.28.8 and ~0.02% overall, all opt-in sharers. That is a sample of+ people who opted into sharing, not a measurement of users.++ A string rather than an int or a bool, and here the encoding is the whole design.+ Measured over a single day, 312,424,709 spans: `vInt64='0'` appears 0 times and+ `vBool='false'` appears 0 times, while `vStr='0'` does appear. So an integer key+ count would have silently dropped exactly the majority case -- 54.46% of sharers+ pass `{}` -- and reproduced the bug this item exists to fix.++ `{}` and `None` are both "false" on purpose: an empty dict parameterises nothing, so+ truthiness is the question being asked.+ """+ crew = _stub_crew(True)+ assert crew.share_crew is False, "the ungated path is the one under test"++ _tracer, span = _emit("crew_creation", crew, inputs)++ span.set_attribute.assert_any_call("crew_inputs_present", expected)+++def test_crew_inputs_payload_stays_gated_while_the_presence_signal_does_not():+ """The split is the point: presence ships for everyone, content ships for nobody new.++ Without this, widening the presence signal could be "fixed" later by simply+ ungating `crew_inputs`, which would put user payloads into telemetry.+ """+ crew = _stub_crew(True)+ assert crew.share_crew is False++ _tracer, span = _emit("crew_creation", crew, {"secret_topic": "acquisition target"})++ emitted = {call.args[0] for call in span.set_attribute.call_args_list}+ assert "crew_inputs_present" in emitted+ assert "crew_inputs" not in emitted, (+ "the payload must remain inside the share_crew branch; only its presence is ungated"+ )+ for call in span.set_attribute.call_args_list:+ assert "secret_topic" not in str(call.args[1]), (+ "no input KEY may reach the span either -- key names are user data too, and a "+ "regression emitting json.dumps(inputs.keys()) would pass a value-only check"+ )+ assert "acquisition target" not in str(call.args[1]), (+ "no input value may reach the span for a non-sharing crew"+ )++@pytest.mark.parametrize(("resumed", "expected"), [(True, "true"), (False, "false")])def test_resumed_is_recorded_as_a_string(resumed: bool, expected: str) -> None:"""A boolean is encoded as the presence of a key, not as a value.