Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/praisonai-agents/praisonaiagents/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .chat_handler import ChatHandlerMixin
from .session_manager import SessionManagerMixin
from .async_safety import AsyncSafeState
from .unified_execution_mixin import UnifiedExecutionMixin

# Module-level logger for thread safety errors and debugging
logger = get_logger(__name__)
Expand Down Expand Up @@ -251,7 +252,7 @@ def _get_default_server_registry() -> ServerRegistry:
# Import structured error from central errors module
from ..errors import BudgetExceededError

class Agent(ToolExecutionMixin, ChatHandlerMixin, SessionManagerMixin, ChatMixin, ExecutionMixin, MemoryMixin, AsyncMemoryMixin):
class Agent(UnifiedExecutionMixin, ToolExecutionMixin, ChatHandlerMixin, SessionManagerMixin, ChatMixin, ExecutionMixin, MemoryMixin, AsyncMemoryMixin):
# Class-level counter for generating unique display names for nameless agents
_agent_counter = 0
_agent_counter_lock = threading.Lock()
Expand Down Expand Up @@ -545,6 +546,7 @@ def __init__(
skills: Optional[Union[List[str], str, Dict[str, Any], 'SkillsConfig']] = None,
approval: Optional[Union[bool, str, Dict[str, Any], 'ApprovalConfig', 'ApprovalProtocol']] = None,
tool_timeout: Optional[int] = None, # P8/G11: Timeout in seconds for each tool call
parallel_tool_calls: bool = False, # Gap 2: Enable parallel execution of batched LLM tool calls
learn: Optional[Union[bool, str, Dict[str, Any], 'LearnConfig']] = None, # Continuous learning (peer to memory)
Comment on lines +549 to 550
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

parallel_tool_calls is silently ignored whenever execution= is set.

ExecutionConfig always has a parallel_tool_calls attribute, so this fallback never uses the constructor value. For example, Agent(execution="fast", parallel_tool_calls=True) still resolves to False, which leaves two public configuration surfaces for the same setting and makes one of them ineffective. Either merge the standalone flag into _exec_config before reading it, or keep this knob exclusively under ExecutionConfig. As per coding guidelines, "Consolidate Agent parameters into Config objects following the pattern: False=disabled, True=defaults, Config=custom (e.g., ExecutionConfig, MemoryConfig, AutonomyConfig, OutputConfig, ReflectionConfig, TemplateConfig, CachingConfig, WebConfig)".

Also applies to: 953-954

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/praisonai-agents/praisonaiagents/agent/agent.py` around lines 548 - 549,
The constructor-level boolean parallel_tool_calls is being ignored when
execution= is provided because ExecutionConfig always defines its own
parallel_tool_calls; update the Agent initialization to consolidate the flag
into the ExecutionConfig path: when parallel_tool_calls is not None and
execution is a str/bool/default, merge or set that value onto the resolved
ExecutionConfig instance (e.g., _exec_config or the variable returned by
resolving execution) so the effective config honors the constructor argument;
alternatively, remove the standalone parameter and require users to supply it
via ExecutionConfig—apply the same consolidation for the other occurrence
referenced around the alternative instantiation (the code handling execution
resolution and _exec_config).

backend: Optional[Any] = None, # External managed agent backend (e.g., ManagedAgentIntegration)
):
Expand Down Expand Up @@ -634,6 +636,10 @@ def __init__(
- LearnConfig: Custom configuration
Learning is a first-class citizen, peer to memory. It captures patterns,
preferences, and insights from interactions to improve future responses.
parallel_tool_calls: Enable parallel execution of batched LLM tool calls (default False).
When True and LLM returns multiple tool calls in a single response, they execute
concurrently instead of sequentially. Provides ~3x speedup for I/O-bound tools.
Maintains backward compatibility with False default.
backend: External managed agent backend for hybrid execution. Accepts:
- ManagedAgentIntegration: External managed agent service
- None: Use local execution (default)
Expand Down Expand Up @@ -768,14 +774,8 @@ def __init__(
alternative="use 'execution=ExecutionConfig(rate_limiter=obj)' instead",
stacklevel=3
)
if parallel_tool_calls is not None:
warn_deprecated_param(
"parallel_tool_calls",
since="1.0.0",
removal="2.0.0",
alternative="use 'execution=ExecutionConfig(parallel_tool_calls=True)' instead",
stacklevel=3
)
# Note: parallel_tool_calls is NOT deprecated - it's a new Gap 2 feature
# Both direct parameter and ExecutionConfig.parallel_tool_calls are supported
if verification_hooks is not None:
warn_deprecated_param(
"verification_hooks",
Expand Down Expand Up @@ -951,17 +951,17 @@ def __init__(
allow_code_execution = True
if _exec_config.code_mode != "safe":
code_execution_mode = _exec_config.code_mode
# Get parallel_tool_calls from ExecutionConfig
parallel_tool_calls = _exec_config.parallel_tool_calls
# Get parallel_tool_calls from ExecutionConfig, fall back to parameter
parallel_tool_calls = getattr(_exec_config, 'parallel_tool_calls', parallel_tool_calls)
# Budget guard extraction
_max_budget = getattr(_exec_config, 'max_budget', None)
_on_budget_exceeded = getattr(_exec_config, 'on_budget_exceeded', 'stop') or 'stop'
else:
max_iter, max_rpm, max_execution_time, max_retry_limit = 20, None, None, 2
_max_budget = None
_on_budget_exceeded = 'stop'
# Default parallel_tool_calls when no ExecutionConfig provided
parallel_tool_calls = False
# Keep parallel_tool_calls parameter value when no ExecutionConfig provided
# (already set from parameter, no need to override)

# ─────────────────────────────────────────────────────────────────────
# Resolve TEMPLATES param - FAST PATH
Expand Down
Loading