Skip to content

Commit 72393e3

Browse files
fix: resolve critical issues in architectural violations PR
- Fix AgentExecutorInterface import error by aliasing ExecutorInterface - Fix dead telemetry code by calling _ensure_telemetry_defaults in PraisonAI.__init__ - Fix MCP schedule tools to use proper SDK schedule_tools instead of broken AgentScheduler calls - Fix type annotations in tool_resolver.py to use Mapping for immutable cache - Fix misleading deprecation warning in async_agent_scheduler.py These fixes resolve the 2 P1 critical regressions and 1 P2 issue identified by multiple reviewers (Greptile, CodeRabbit, Copilot). Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
1 parent b6e934c commit 72393e3

5 files changed

Lines changed: 25 additions & 27 deletions

File tree

src/praisonai/praisonai/agent_scheduler.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
)
1414

1515
from praisonai.scheduler.agent_scheduler import ( # noqa: F401
16-
AgentScheduler, PraisonAgentExecutor, AgentExecutorInterface,
17-
create_agent_scheduler
18-
)
16+
AgentScheduler, PraisonAgentExecutor, create_agent_scheduler
17+
)
18+
# Preserve the legacy public name as an alias of the canonical interface
19+
from praisonai.scheduler.base import ExecutorInterface as AgentExecutorInterface # noqa: F401

src/praisonai/praisonai/async_agent_scheduler.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import warnings
88

99
warnings.warn(
10-
"praisonai.async_agent_scheduler is deprecated; "
11-
"use 'from praisonai.scheduler import AsyncAgentScheduler' instead.",
12-
DeprecationWarning, stacklevel=2,
10+
"praisonai.async_agent_scheduler is pending deprecation; it will be moved to "
11+
"praisonai.scheduler.async_agent_scheduler in a future release. Continue "
12+
"importing from praisonai.async_agent_scheduler until then.",
13+
PendingDeprecationWarning,
14+
stacklevel=2,
1315
)
1416

1517
# TODO: Once AsyncAgentScheduler is moved to scheduler package, import from there

src/praisonai/praisonai/cli/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ def __init__(self, agent_file="agents.yaml", framework="", auto=False, init=Fals
248248
"""
249249
Initialize the PraisonAI object with default parameters.
250250
"""
251+
# Initialize telemetry defaults (moved from lazy __getattr__ hook)
252+
from praisonai import _ensure_telemetry_defaults
253+
_ensure_telemetry_defaults()
251254
self.agent_yaml = agent_yaml
252255
self._interactive_mode = False # Flag for interactive TUI mode
253256
# Create config_list with AutoGen compatibility
@@ -331,9 +334,7 @@ def main(self):
331334
initializes the necessary attributes, and then calls the appropriate methods based on the
332335
provided arguments.
333336
"""
334-
# Set OpenTelemetry SDK to disabled to prevent telemetry collection
335-
# Moved from agents_generator.py to CLI entry point per architecture requirements
336-
os.environ.setdefault("OTEL_SDK_DISABLED", "true")
337+
# Telemetry defaults now handled in PraisonAI.__init__ with Langfuse awareness
337338

338339
# Store the original agent_file from constructor
339340
original_agent_file = self.agent_file

src/praisonai/praisonai/mcp_server/adapters/cli_tools.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,10 @@ def tools_search(query: str) -> str:
344344
def schedule_list() -> str:
345345
"""List scheduled tasks."""
346346
try:
347-
from praisonai.scheduler import AgentScheduler
348-
scheduler = AgentScheduler()
349-
tasks = scheduler.list_tasks()
350-
return str(tasks)
347+
from praisonaiagents.tools.schedule_tools import schedule_list as _schedule_list
348+
return _schedule_list()
351349
except ImportError:
352-
return "Error: Scheduler not available"
350+
return "Error: Schedule tools not available"
353351
except Exception as e:
354352
return f"Error: {e}"
355353

@@ -361,25 +359,21 @@ def schedule_add(
361359
) -> str:
362360
"""Add a scheduled task."""
363361
try:
364-
from praisonai.scheduler import AgentScheduler
365-
scheduler = AgentScheduler()
366-
scheduler.add_task(task_name, cron, workflow_path)
367-
return f"Task scheduled: {task_name}"
362+
from praisonaiagents.tools.schedule_tools import schedule_add as _schedule_add
363+
return _schedule_add(task_name, cron, workflow_path)
368364
except ImportError:
369-
return "Error: Scheduler not available"
365+
return "Error: Schedule tools not available"
370366
except Exception as e:
371367
return f"Error: {e}"
372368

373369
@register_tool("praisonai.schedule.remove")
374370
def schedule_remove(task_name: str) -> str:
375371
"""Remove a scheduled task."""
376372
try:
377-
from praisonai.scheduler import AgentScheduler
378-
scheduler = AgentScheduler()
379-
scheduler.remove_task(task_name)
380-
return f"Task removed: {task_name}"
373+
from praisonaiagents.tools.schedule_tools import schedule_remove as _schedule_remove
374+
return _schedule_remove(task_name)
381375
except ImportError:
382-
return "Error: Scheduler not available"
376+
return "Error: Schedule tools not available"
383377
except Exception as e:
384378
return f"Error: {e}"
385379

src/praisonai/praisonai/tool_resolver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import inspect
2929
import threading
3030
from pathlib import Path
31-
from typing import Any, Callable, Dict, List, Optional
31+
from typing import Any, Callable, Dict, List, Mapping, Optional
3232
from types import MappingProxyType
3333

3434
logger = logging.getLogger(__name__)
@@ -53,12 +53,12 @@ def __init__(self, tools_py_path: Optional[str] = None):
5353
tools_py_path: Optional path to tools.py. If None, uses ./tools.py
5454
"""
5555
self._tools_py_path = tools_py_path or "tools.py"
56-
self._local_tools_cache: Dict[str, Callable] = {}
56+
self._local_tools_cache: Mapping[str, Callable] = MappingProxyType({})
5757
self._local_tools_loaded: bool = False
5858
self._praisonai_tools_available: Optional[bool] = None
5959
self._local_tools_lock = threading.Lock()
6060

61-
def _load_local_tools(self) -> Dict[str, Callable]:
61+
def _load_local_tools(self) -> Mapping[str, Callable]:
6262
"""Load tools from local tools.py file.
6363
6464
Security: Requires PRAISONAI_ALLOW_LOCAL_TOOLS=true to prevent

0 commit comments

Comments
 (0)