fix: resolve additional mypy type errors

- Fix tool_usage.py: proper type annotations for result and fingerprint metadata
- Fix lite_agent.py: proper Union type for guardrail callable accepting both LiteAgentOutput and TaskOutput
- Add missing return type annotations to task_output_storage_handler.py methods
- Fix crew.py: replace Json generic check with str, remove unused type:ignore and redundant cast
This commit is contained in:
Greyson LaLonde
2025-09-03 23:23:36 -04:00
parent b6e7311d2d
commit eed2ffde5f
4 changed files with 12 additions and 10 deletions

View File

@@ -5,6 +5,7 @@ from collections.abc import Callable
from typing import (
Any,
Optional,
Union,
cast,
get_args,
get_origin,
@@ -39,6 +40,7 @@ from crewai.events.types.logging_events import AgentLogsExecutionEvent
from crewai.flow.flow_trackable import FlowTrackable
from crewai.llm import LLM
from crewai.llms.base_llm import BaseLLM
from crewai.task import TaskOutput
from crewai.tools.base_tool import BaseTool
from crewai.tools.structured_tool import CrewStructuredTool
from crewai.utilities import I18N
@@ -185,8 +187,8 @@ class LiteAgent(FlowTrackable, BaseModel):
_messages: list[dict[str, str]] = PrivateAttr(default_factory=list)
_iterations: int = PrivateAttr(default=0)
_printer: Printer = PrivateAttr(default_factory=Printer)
_guardrail: Optional[Callable[[LiteAgentOutput], tuple[bool, Any]]] = PrivateAttr(
default=None
_guardrail: Optional[Callable[[LiteAgentOutput | TaskOutput], tuple[bool, Any]]] = (
PrivateAttr(default=None)
)
_guardrail_retry_count: int = PrivateAttr(default=0)