Skip to content

Commit 3a2a2f8

Browse files
Merge pull request #1185 from MervinPraison/claude/fix-agent-type-hints-20260330
Type hints PR - MERGEABLE, low risk, improves IDE support. Unit tests: 4473 passed. Integration: 294 passed.
2 parents 3193d19 + d143cce commit 3a2a2f8

1 file changed

Lines changed: 29 additions & 29 deletions

File tree

  • src/praisonai-agents/praisonaiagents/agent

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,14 @@ def _hook_runner(self):
220220
return self.__hook_runner
221221

222222
@property
223-
def stream_emitter(self):
223+
def stream_emitter(self) -> Optional[Any]:
224224
"""Lazy-loaded StreamEventEmitter for real-time events (zero overhead when not used)."""
225225
if self.__stream_emitter is None:
226226
self.__stream_emitter = _get_stream_emitter()()
227227
return self.__stream_emitter
228228

229229
@stream_emitter.setter
230-
def stream_emitter(self, value):
230+
def stream_emitter(self, value: Optional[Any]) -> None:
231231
"""Allow setting stream_emitter directly."""
232232
self.__stream_emitter = value
233233

@@ -1875,57 +1875,57 @@ def _cache_get(self, cache_dict, key):
18751875
return value
18761876

18771877
@property
1878-
def auto_memory(self):
1878+
def auto_memory(self) -> Optional[bool]:
18791879
"""AutoMemory instance for automatic memory extraction."""
18801880
return self._auto_memory
18811881

18821882
@auto_memory.setter
1883-
def auto_memory(self, value):
1883+
def auto_memory(self, value: Optional[bool]) -> None:
18841884
self._auto_memory = value
18851885

18861886
@property
1887-
def policy(self):
1887+
def policy(self) -> Optional[Any]:
18881888
"""PolicyEngine instance for execution control."""
18891889
return self._policy
18901890

18911891
@policy.setter
1892-
def policy(self, value):
1892+
def policy(self, value: Optional[Any]) -> None:
18931893
self._policy = value
18941894

18951895
@property
1896-
def background(self):
1896+
def background(self) -> Optional[bool]:
18971897
"""BackgroundRunner instance for async task execution."""
18981898
return self._background
18991899

19001900
@background.setter
1901-
def background(self, value):
1901+
def background(self, value: Optional[bool]) -> None:
19021902
self._background = value
19031903

19041904
@property
1905-
def checkpoints(self):
1905+
def checkpoints(self) -> Optional[bool]:
19061906
"""CheckpointService instance for file-level undo/restore."""
19071907
return self._checkpoints
19081908

19091909
@checkpoints.setter
1910-
def checkpoints(self, value):
1910+
def checkpoints(self, value: Optional[bool]) -> None:
19111911
self._checkpoints = value
19121912

19131913
@property
1914-
def output_style(self):
1914+
def output_style(self) -> Optional[str]:
19151915
"""OutputStyle instance for response formatting."""
19161916
return self._output_style
19171917

19181918
@output_style.setter
1919-
def output_style(self, value):
1919+
def output_style(self, value: Optional[str]) -> None:
19201920
self._output_style = value
19211921

19221922
@property
1923-
def thinking_budget(self):
1923+
def thinking_budget(self) -> Optional[int]:
19241924
"""ThinkingBudget instance for extended thinking control."""
19251925
return self._thinking_budget
19261926

19271927
@thinking_budget.setter
1928-
def thinking_budget(self, value):
1928+
def thinking_budget(self, value: Optional[int]) -> None:
19291929
self._thinking_budget = value
19301930

19311931
@property
@@ -1948,7 +1948,7 @@ def cost_summary(self) -> dict:
19481948
}
19491949

19501950
@property
1951-
def context_manager(self):
1951+
def context_manager(self) -> Optional[Any]:
19521952
"""
19531953
ContextManager instance for unified context management.
19541954
@@ -2091,7 +2091,7 @@ def llm_summarize(messages: List[Dict[str, Any]], max_tokens: int = 500) -> str:
20912091
return llm_summarize
20922092

20932093
@property
2094-
def console(self):
2094+
def console(self) -> Optional[Any]:
20952095
"""Lazily initialize Rich Console only when needed AND verbose is True."""
20962096
# Only return console if verbose mode is enabled
20972097
# This prevents panels from being shown in status/silent modes
@@ -2103,7 +2103,7 @@ def console(self):
21032103
return self._console
21042104

21052105
@property
2106-
def skill_manager(self):
2106+
def skill_manager(self) -> Optional[Any]:
21072107
"""Lazily initialize SkillManager only when skills are accessed."""
21082108
if self._skill_manager is None and (self._skills or self._skills_dirs):
21092109
from ..skills import SkillManager
@@ -2187,7 +2187,7 @@ def _openai_client(self):
21872187
return self.__openai_client
21882188

21892189
@property
2190-
def agent_id(self):
2190+
def agent_id(self) -> str:
21912191
"""Lazily generate agent ID when first accessed."""
21922192
if self._agent_id is None:
21932193
import uuid
@@ -3624,7 +3624,7 @@ def _model_supports_prompt_caching(self) -> bool:
36243624
return supports_prompt_caching(model_name)
36253625

36263626
@property
3627-
def rules_manager(self):
3627+
def rules_manager(self) -> Optional[Any]:
36283628
"""
36293629
Lazy-initialized RulesManager for persistent rules/instructions.
36303630
@@ -3805,7 +3805,7 @@ def get_learn_context(self) -> str:
38053805

38063806
return ""
38073807

3808-
def store_memory(self, content: str, memory_type: str = "short_term", **kwargs):
3808+
def store_memory(self, content: str, memory_type: str = "short_term", **kwargs: Any) -> None:
38093809
"""
38103810
Store content in memory.
38113811
@@ -3877,7 +3877,7 @@ def _display_memory_info(self):
38773877
))
38783878

38793879
@property
3880-
def llm_model(self):
3880+
def llm_model(self) -> Optional[str]:
38813881
"""Unified property to get the LLM model regardless of configuration type.
38823882
38833883
Returns:
@@ -3913,12 +3913,12 @@ def _ensure_knowledge_processed(self):
39133913
self._knowledge_processed = True
39143914

39153915
@property
3916-
def retrieval_config(self):
3916+
def retrieval_config(self) -> Optional[Any]:
39173917
"""Get the unified retrieval configuration."""
39183918
return self._retrieval_config
39193919

39203920
@property
3921-
def rag(self):
3921+
def rag(self) -> Optional[Any]:
39223922
"""
39233923
Lazy-loaded RAG instance for advanced retrieval with citations.
39243924
@@ -4846,7 +4846,7 @@ def _cast_arguments(self, func, arguments):
48464846
logging.debug(f"Type casting failed for {getattr(func, '__name__', 'unknown function')}: {e}")
48474847
return arguments
48484848

4849-
def execute_tool(self, function_name, arguments, tool_call_id=None):
4849+
def execute_tool(self, function_name: str, arguments: Dict[str, Any], tool_call_id: Optional[str] = None) -> Any:
48504850
"""
48514851
Execute a tool dynamically based on the function name and arguments.
48524852
Injects agent state for tools with Injected[T] parameters.
@@ -5529,7 +5529,7 @@ def get_history_size(self) -> int:
55295529
return len(self.chat_history)
55305530

55315531
@contextlib.contextmanager
5532-
def ephemeral(self):
5532+
def ephemeral(self) -> Generator[None, None, None]:
55335533
"""
55345534
Context manager for ephemeral conversations.
55355535
@@ -6252,7 +6252,7 @@ def as_tool(
62526252
config=HandoffConfig(context_policy=ContextPolicy.NONE),
62536253
)
62546254

6255-
def chat(self, prompt, temperature=1.0, tools=None, output_json=None, output_pydantic=None, reasoning_steps=False, stream=None, task_name=None, task_description=None, task_id=None, config=None, force_retrieval=False, skip_retrieval=False, attachments=None, tool_choice=None):
6255+
def chat(self, prompt: str, temperature: float = 1.0, tools: Optional[List[Any]] = None, output_json: Optional[Any] = None, output_pydantic: Optional[Any] = None, reasoning_steps: bool = False, stream: Optional[bool] = None, task_name: Optional[str] = None, task_description: Optional[str] = None, task_id: Optional[str] = None, config: Optional[Dict[str, Any]] = None, force_retrieval: bool = False, skip_retrieval: bool = False, attachments: Optional[List[str]] = None, tool_choice: Optional[str] = None) -> Optional[str]:
62566256
"""
62576257
Chat with the agent.
62586258
@@ -7415,7 +7415,7 @@ async def astart(self, prompt: str, **kwargs):
74157415
kwargs['stream'] = stream_requested
74167416
return await self.achat(prompt, **kwargs)
74177417

7418-
def run(self, prompt: str, **kwargs):
7418+
def run(self, prompt: str, **kwargs: Any) -> Optional[str]:
74197419
"""Execute agent silently and return structured result.
74207420
74217421
Production-friendly execution. Always uses silent mode with no streaming
@@ -7601,7 +7601,7 @@ def switch_model(self, new_model: str) -> None:
76017601

76027602
# Chat history is preserved in self.chat_history (no action needed)
76037603

7604-
def start(self, prompt: str = None, **kwargs):
7604+
def start(self, prompt: Optional[str] = None, **kwargs: Any) -> Union[str, Generator[str, None, None], None]:
76057605
"""Start the agent interactively with verbose output.
76067606
76077607
Beginner-friendly execution. Defaults to verbose output with streaming
@@ -8554,7 +8554,7 @@ def pending_approval_count(self) -> int:
85548554
"""Number of approval requests still waiting."""
85558555
return len(self._pending_approvals)
85568556

8557-
def execute(self, task, context=None):
8557+
def execute(self, task: Any, context: Optional[Any] = None) -> Optional[str]:
85588558
"""Execute a task synchronously - backward compatibility method"""
85598559
if hasattr(task, 'description'):
85608560
prompt = task.description

0 commit comments

Comments
 (0)