Skip to content

Commit 724e4af

Browse files
fix(types): address reviewer feedback on agent init type hints
- Narrow context hint: remove str/Dict (init has no handling for those) - Narrow autonomy hint: remove str (no string-level preset handling) - Narrow templates hint: remove str (resolve() returns None with no presets) - Narrow approval hint: remove Dict (init only handles bool/str/ApprovalConfig/Protocol) - Narrow learn hint: remove str; replace silent passthrough with a logged warning - Update docstrings for output/execution/templates/learn to reflect actual supported types Agent-Logs-Url: https://github.com/MervinPraison/PraisonAI/sessions/e371c8e1-a816-4fb2-8eb8-a18242daa2de Co-authored-by: MervinPraison <454862+MervinPraison@users.noreply.github.com>
1 parent 72e477f commit 724e4af

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

  • src/praisonai-agents/praisonaiagents/agent

src/praisonai-agents/praisonaiagents/agent/agent.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,18 +488,18 @@ def __init__(
488488
reflection: Optional[Union[bool, str, 'ReflectionConfig']] = None,
489489
guardrails: Optional[Union[bool, str, Callable, 'GuardrailConfig']] = None,
490490
web: Optional[Union[bool, str, 'WebConfig']] = None,
491-
context: Optional[Union[bool, str, Dict[str, Any], 'ContextConfig', 'ContextManager']] = None,
492-
autonomy: Optional[Union[bool, str, Dict[str, Any], 'AutonomyConfig']] = None,
491+
context: Optional[Union[bool, 'ContextConfig', 'ContextManager']] = None,
492+
autonomy: Optional[Union[bool, Dict[str, Any], 'AutonomyConfig']] = None,
493493
verification_hooks: Optional[List[Any]] = None, # Deprecated: use autonomy=AutonomyConfig(verification_hooks=[...])
494494
output: Optional[Union[bool, str, Dict[str, Any], 'OutputConfig']] = None,
495495
execution: Optional[Union[bool, str, Dict[str, Any], 'ExecutionConfig']] = None,
496-
templates: Optional[Union[str, Dict[str, Any], 'TemplateConfig']] = None,
496+
templates: Optional[Union[Dict[str, Any], 'TemplateConfig']] = None,
497497
caching: Optional[Union[bool, str, Dict[str, Any], 'CachingConfig']] = None,
498498
hooks: Optional[Union[List[Any], Dict[str, Any], 'HooksConfig']] = None,
499499
skills: Optional[Union[List[str], str, Dict[str, Any], 'SkillsConfig']] = None,
500-
approval: Optional[Union[bool, str, Dict[str, Any], 'ApprovalConfig', 'ApprovalProtocol']] = None,
500+
approval: Optional[Union[bool, str, 'ApprovalConfig', 'ApprovalProtocol']] = None,
501501
tool_timeout: Optional[int] = None, # P8/G11: Timeout in seconds for each tool call
502-
learn: Optional[Union[bool, str, Dict[str, Any], 'LearnConfig']] = None, # Continuous learning (peer to memory)
502+
learn: Optional[Union[bool, Dict[str, Any], 'LearnConfig']] = None, # Continuous learning (peer to memory)
503503
):
504504
"""Initialize an Agent instance.
505505
@@ -552,14 +552,20 @@ def __init__(
552552
verification_hooks: **Deprecated** — use ``autonomy=AutonomyConfig(verification_hooks=[...])``.
553553
Still works for backward compatibility.
554554
output: Output configuration. Accepts:
555+
- bool: True=default OutputConfig, False=disabled
555556
- str: Preset name ("silent", "actions", "verbose", "json", "stream")
557+
- Dict[str, Any]: Config overrides (e.g. {"verbose": 2, "stream": True})
556558
- OutputConfig: Custom configuration
557559
Controls: verbose, markdown, stream, metrics, reasoning_steps
558560
execution: Execution configuration. Accepts:
561+
- bool: True=default ExecutionConfig, False=disabled
559562
- str: Preset name ("fast", "balanced", "thorough")
563+
- Dict[str, Any]: Config overrides (e.g. {"max_iter": 10, "max_rpm": 60})
560564
- ExecutionConfig: Custom configuration
561565
Controls: max_iter, max_rpm, max_execution_time, max_retry_limit
562-
templates: Template configuration (TemplateConfig).
566+
templates: Template configuration. Accepts:
567+
- Dict[str, Any]: Template fields (e.g. {"system": "...", "prompt": "..."})
568+
- TemplateConfig: Custom configuration
563569
Controls: system_template, prompt_template, response_template
564570
caching: Caching configuration. Accepts:
565571
- bool: True enables with defaults
@@ -571,7 +577,8 @@ def __init__(
571577
- List[str]: Skill directory paths
572578
- SkillsConfig: Custom configuration
573579
learn: Continuous learning configuration. Accepts:
574-
- bool: True enables with defaults, False disables
580+
- bool: True enables with defaults (AGENTIC mode), False disables
581+
- Dict[str, Any]: Config fields (e.g. {"mode": "agentic", "backend": "sqlite"})
575582
- LearnConfig: Custom configuration
576583
Learning is a first-class citizen, peer to memory. It captures patterns,
577584
preferences, and insights from interactions to improve future responses.
@@ -1089,7 +1096,11 @@ def __init__(
10891096
# Unknown string mode, disable learning
10901097
_learn_config = None
10911098
else:
1092-
_learn_config = learn # Pass through
1099+
logging.warning(
1100+
"Unsupported learn= value %r; expected bool, dict, or LearnConfig. "
1101+
"Learning disabled.", learn
1102+
)
1103+
_learn_config = None
10931104
elif _memory_config is not None and isinstance(_memory_config, MemoryConfig):
10941105
# Fallback to memory.learn for backward compatibility
10951106
if _memory_config.learn:

0 commit comments

Comments
 (0)