diff --git a/features/steps/tdd_actor_run_response_steps.py b/features/steps/tdd_actor_run_response_steps.py new file mode 100644 index 000000000..1c1f012cc --- /dev/null +++ b/features/steps/tdd_actor_run_response_steps.py @@ -0,0 +1,70 @@ +"""Step definitions for TDD test: agents actor run returns no useful response. + +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}" diff --git a/features/tdd_actor_run_response.feature b/features/tdd_actor_run_response.feature new file mode 100644 index 000000000..da0fee385 --- /dev/null +++ b/features/tdd_actor_run_response.feature @@ -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" \ No newline at end of file