bstraehle commited on
Commit
1e5ce5b
·
verified ·
1 Parent(s): d2f486f

Update agents/crew.py

Browse files
Files changed (1) hide show
  1. agents/crew.py +26 -9
agents/crew.py CHANGED
@@ -3,23 +3,40 @@
3
  # https://docs.crewai.com/introduction
4
  # https://arize.com/docs/phoenix/integrations/python/crewai/crewai-tracing
5
 
6
- import logging, os, sys
 
 
7
 
8
- #os.environ["CREWAI_TRACING_ENABLED"] = "0" # Arize Phoenix
9
-
10
- # Disable CrewAI tracing completely
11
  os.environ["CREWAI_TRACING_ENABLED"] = "false"
12
-
13
- # Suppress the interactive tracing prompt by simulating non-TTY environment
14
  os.environ["CREWAI_DISABLE_TELEMETRY"] = "true"
15
 
16
- # Redirect stdin to devnull to prevent interactive prompts
17
- if hasattr(sys, 'stdin'):
 
 
 
 
18
  try:
19
- sys.stdin = open(os.devnull, 'r')
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  except:
21
  pass
22
 
 
 
23
  from agents.models.llms import (
24
  LLM_CREW_MANAGER,
25
  LLM_CREW_PLANNING,
 
3
  # https://docs.crewai.com/introduction
4
  # https://arize.com/docs/phoenix/integrations/python/crewai/crewai-tracing
5
 
6
+ import logging
7
+ import os
8
+ import sys
9
 
10
+ # Disable CrewAI tracing completely and suppress all tracing messages
 
 
11
  os.environ["CREWAI_TRACING_ENABLED"] = "false"
 
 
12
  os.environ["CREWAI_DISABLE_TELEMETRY"] = "true"
13
 
14
+ # Mark as not first execution to skip the "Tracing Preference Saved" message
15
+ import json
16
+ from pathlib import Path
17
+
18
+ def _suppress_first_time_trace_message():
19
+ """Pre-populate user data to prevent first-time tracing message."""
20
  try:
21
+ # Determine the user data path (matches CrewAI's db_storage_path logic)
22
+ base_path = Path.home() / ".crewai" / "data"
23
+ base_path.mkdir(parents=True, exist_ok=True)
24
+ user_data_file = base_path / ".crewai_user.json"
25
+
26
+ # Pre-populate with tracing declined
27
+ user_data = {
28
+ "first_execution_done": True,
29
+ "trace_consent": False
30
+ }
31
+
32
+ # Only write if file doesn't exist
33
+ if not user_data_file.exists():
34
+ user_data_file.write_text(json.dumps(user_data, indent=2))
35
  except:
36
  pass
37
 
38
+ _suppress_first_time_trace_message()
39
+
40
  from agents.models.llms import (
41
  LLM_CREW_MANAGER,
42
  LLM_CREW_PLANNING,