fix: address PR #5788 review comments

- Remove dead `env_vars.get("MODEL")` check in _setup_env (always truthy
  since MODEL is set two lines above)
- Fix test_sync_delegation mock: use return_value instead of side_effect
  list and disable planning to prevent StopAsyncIteration on Python 3.10

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Joao Moura
2026-05-14 13:08:40 -04:00
parent f723e69410
commit 16488f5fe5
2 changed files with 7 additions and 6 deletions

View File

@@ -776,7 +776,7 @@ def _setup_env(base: Path, llm_model: str) -> None:
for details in ENV_VARS.get(provider, [])
if "key_name" in details
)
if already_set and env_vars.get("MODEL"):
if already_set:
return
if provider in ENV_VARS:

View File

@@ -377,12 +377,13 @@ class TestDelegation:
@patch("crewai.new_agent.executor.aget_llm_response")
@pytest.mark.asyncio
async def test_sync_delegation(self, mock_llm_response):
mock_llm_response.side_effect = [
"Draft article about AI.", # writer's response
"Here is the summary based on the writer's output.", # manager's response
]
mock_llm_response.return_value = "Draft article about AI."
writer = NewAgent(role="Writer", goal="Write articles")
writer = NewAgent(
role="Writer",
goal="Write articles",
settings={"planning_enabled": False},
)
tool = DelegateToCoworkerTool(coworker=writer)
result = tool._run(message="Write an article about AI")