test(actor): Capture failing assertion for actor-run returning no response #10893

Merged
HAL9000 merged 1 commits from tdd/m3-actor-run-response into master 2026-04-29 07:15:39 +00:00
2 changed files with 82 additions and 0 deletions
@@ -0,0 +1,70 @@
"""Step definitions for TDD test: agents actor run returns no useful response.
Outdated
Review

Suggestion: Per project import rules (all imports at top of file, except if TYPE_CHECKING:), move the SimpleLLMAgent import from inside step_invoke_actor_run (~line 114) to module top.

Suggestion: Per project import rules (all imports at top of file, except if TYPE_CHECKING:), move the SimpleLLMAgent import from inside step_invoke_actor_run (~line 114) to module top.
Outdated
Review

Suggestion: The temp file cleanup in step_invoke_actor_run (lines 130-132) deletes files before Then step assertions. Consider saving paths to context before cleanup so they remain for inspection on failure.

Suggestion: The temp file cleanup in step_invoke_actor_run (lines 130-132) deletes files before Then step assertions. Consider saving paths to context before cleanup so they remain for inspection on failure.
Issue: #10861 — agents actor run does not work
TDD Issue: #10862
This test captures the bug: when `agents actor run` is invoked with a built-in
LLM actor name resolved from the registry, the command returns no useful
response (either empty or an error).
The @tdd_expected_fail tag inverts the result so CI passes while the bug exists.
Once the fix is applied, the @tdd_expected_fail tag must be removed and the
test must pass normally.
"""
from __future__ import annotations
from typing import Any
from unittest.mock import MagicMock, patch
from behave import given, then, when
from typer.testing import CliRunner
from cleveragents.cli.commands.actor import app as actor_app
@given("I have a mock LLM that returns {response}")
def step_have_mock_llm(context: Any, response: str) -> None:
"""Create a mock LLM that returns the specified response."""
context.mock_llm_response = response
context.mock_llm = MagicMock()
mock_response = MagicMock()
mock_response.content = response
context.mock_llm.invoke.return_value = mock_response
@when("I run actor run with the built-in actor name and prompt {prompt}")
def step_run_actor_run_with_builtin(context: Any, prompt: str) -> None:
"""Invoke `agents actor run` with a built-in actor name and prompt."""
context.prompt = prompt
actor_name = next(
(name for name in context.actor_service.actors if "anthropic" in name.lower()),
None,
)
if not actor_name:
raise AssertionError("No built-in anthropic actor found")
context.actor_name = actor_name
context.runner = CliRunner()
def run_with_mocks():
with patch(
"cleveragents.providers.registry.ProviderRegistry.create_llm",
return_value=context.mock_llm,
):
return context.runner.invoke(
actor_app,
["run", actor_name, prompt],
)
context.result = run_with_mocks()
@then("the actor run should return {expected}")
def step_actor_run_should_return(context: Any, expected: str) -> None:
"""Assert that the actor run command returned the expected response."""
output = context.result.output or ""
stderr = getattr(context.result, "stderr", "") or ""
combined = output + stderr
assert expected in combined, f"Expected '{expected}' in output: {combined!r}"
+12
View File
@@ -0,0 +1,12 @@
@tdd_issue @tdd_issue_10861 @tdd_expected_fail
Feature: TDD Issue #10862 — agents actor run returns no useful response
As a user who invokes `agents actor run` with a built-in LLM actor
I want to receive the LLM's response
So that the command is useful
Scenario: Actor run with built-in LLM actor returns the LLM response
Given a configured provider registry with anthropic/claude-sonnet-4-20250514
And the built-in actors have been ensured
And I have a mock LLM that returns "feep"
When I run actor run with the built-in actor name and prompt "ping"
Then the actor run should return "feep"