diff --git a/features/steps/tui_first_run_steps.py b/features/steps/tui_first_run_steps.py index 69a51f462..a89d7b020 100644 --- a/features/steps/tui_first_run_steps.py +++ b/features/steps/tui_first_run_steps.py @@ -536,7 +536,9 @@ def step_actor_service_with_temperature(context: object, actor: str) -> None: context._actor_service = mock_service -@given('an actor service with a mock actor "{actor}" with thinking_effort and temperature arguments') +@given( + 'an actor service with a mock actor "{actor}" with thinking_effort and temperature arguments' +) def step_actor_service_with_both(context: object, actor: str) -> None: from cleveragents.domain.models.core import Actor @@ -580,6 +582,13 @@ def step_actor_service_with_no_args(context: object, actor: str) -> None: context._actor_service = mock_service +@given("an actor service that raises an exception on get_actor") +def step_actor_service_raises_exception(context: object) -> None: + mock_service = MagicMock() + mock_service.get_actor.side_effect = RuntimeError("Actor not found") + context._actor_service = mock_service + + @when('I call create_default_persona_for_actor with actor "{actor}" and actor_service') def step_create_persona_with_service(context: object, actor: str) -> None: from cleveragents.tui.first_run import create_default_persona_for_actor @@ -595,12 +604,12 @@ def step_persona_has_preset(context: object, preset_name: str) -> None: assert persona is not None, "Expected persona 'default' in registry" preset_names = [p.name for p in persona.argument_presets] assert preset_name in preset_names, ( - f"Expected preset '{preset_name}' in persona presets, " - f"got: {preset_names}" + f"Expected preset '{preset_name}' in persona presets, got: {preset_names}" ) -@then('the default persona should have exactly {count:d} preset') +@then("the default persona should have exactly {count:d} preset") +@then("the default persona should have exactly {count:d} presets") def step_persona_has_exact_presets(context: object, count: int) -> None: persona = context._registry.get("default") assert persona is not None, "Expected persona 'default' in registry" diff --git a/features/tui_first_run.feature b/features/tui_first_run.feature index 310b0f819..c94673ede 100644 --- a/features/tui_first_run.feature +++ b/features/tui_first_run.feature @@ -207,6 +207,7 @@ Feature: TUI first-run experience with actor selection overlay And the default persona should have preset "default" And the default persona should have preset "think: high" And the default persona should have preset "think: max" + And the default persona should have exactly 3 presets Scenario: create_default_persona_for_actor auto-generates presets for actor with temperature Given an empty persona registry @@ -242,3 +243,11 @@ Feature: TUI first-run experience with actor selection overlay Then the registry should contain a persona named "default" And the default persona should have preset "default" And the default persona should have exactly 1 preset + + Scenario: create_default_persona_for_actor falls back to default preset when actor lookup fails + Given an empty persona registry + And an actor service that raises an exception on get_actor + When I call create_default_persona_for_actor with actor "anthropic/claude-4-sonnet" and actor_service + Then the registry should contain a persona named "default" + And the default persona should have preset "default" + And the default persona should have exactly 1 preset diff --git a/src/cleveragents/tui/first_run.py b/src/cleveragents/tui/first_run.py index 2dda2530a..31db030cc 100644 --- a/src/cleveragents/tui/first_run.py +++ b/src/cleveragents/tui/first_run.py @@ -148,9 +148,7 @@ def create_default_persona_for_actor( presets = _auto_generate_presets(actor_service, actor) else: # Default to just the default preset - presets = [ - PersonaPreset(name="default", display="default", overrides={}) - ] + presets = [PersonaPreset(name="default", display="default", overrides={})] persona = Persona( name="default",