fix: make task required in CrewAgentExecutor and fix all type annotations

- Make task parameter required in CrewAgentExecutor.__init__
- Update Agent.create_agent_executor to require task parameter
- Handle cases where crew can be None (standalone agent usage)
- Update base class signatures to match
- Remove unnecessary create_agent_executor calls during setup
- Add missing type annotations in base_agent_executor_mixin
- Fix all type errors in base_agent.py using Self return type
- Add assert for agent_executor before use
- Fix crew access checks to handle None case
This commit is contained in:
Greyson LaLonde
2025-09-04 22:13:46 -04:00
parent 2faa13ddcb
commit 843801f554
9 changed files with 228 additions and 169 deletions

View File

@@ -1116,7 +1116,9 @@ def test_not_using_system_prompt():
use_system_prompt=False,
)
agent.create_agent_executor()
# Create a dummy task for testing
task = Task(description="Test task", expected_output="Test output", agent=agent)
agent.create_agent_executor(task)
assert not agent.agent_executor.prompt.get("user")
assert not agent.agent_executor.prompt.get("system")
@@ -1128,7 +1130,9 @@ def test_using_system_prompt():
backstory="I am the master of {role}",
)
agent.create_agent_executor()
# Create a dummy task for testing
task = Task(description="Test task", expected_output="Test output", agent=agent)
agent.create_agent_executor(task)
assert agent.agent_executor.prompt.get("user")
assert agent.agent_executor.prompt.get("system")