test(actor): fix actor examples test suite issues
- Add missing node descriptions in Behave test scenarios - Fix context_view and parallel execution step definitions - Update llm_with_tools.yaml max_context_tokens (10000 → 16000) - Add context.error compatibility for error assertions Results: Behave 25/25, Robot 16/16, ASV 7/7 all newly added tests passing.
This commit is contained in:
@@ -59,7 +59,7 @@ memory:
|
||||
max_tokens: 6000
|
||||
|
||||
context:
|
||||
max_context_tokens: 10000
|
||||
max_context_tokens: 16000
|
||||
|
||||
# Environment variables
|
||||
env_vars:
|
||||
|
||||
@@ -298,12 +298,14 @@ Feature: Actor YAML examples validation
|
||||
- id: success
|
||||
type: agent
|
||||
name: Success Handler
|
||||
description: Handles success case
|
||||
config:
|
||||
model: gpt-4
|
||||
prompt: "Handle success"
|
||||
- id: failure
|
||||
type: agent
|
||||
name: Failure Handler
|
||||
description: Handles failure case
|
||||
config:
|
||||
model: gpt-4
|
||||
prompt: "Handle failure"
|
||||
@@ -339,6 +341,7 @@ Feature: Actor YAML examples validation
|
||||
- id: reader
|
||||
type: agent
|
||||
name: Reader
|
||||
description: Reads and analyzes files
|
||||
config:
|
||||
model: gpt-4
|
||||
prompt: "Read and analyze"
|
||||
@@ -355,6 +358,7 @@ Feature: Actor YAML examples validation
|
||||
- id: writer
|
||||
type: agent
|
||||
name: Writer
|
||||
description: Writes results to files
|
||||
config:
|
||||
model: gpt-4
|
||||
prompt: "Write results"
|
||||
@@ -391,6 +395,7 @@ Feature: Actor YAML examples validation
|
||||
- id: planner
|
||||
type: agent
|
||||
name: Planner
|
||||
description: Creates execution plan
|
||||
config:
|
||||
model: gpt-4
|
||||
prompt: "Create plan"
|
||||
@@ -405,6 +410,7 @@ Feature: Actor YAML examples validation
|
||||
- id: reviewer_subgraph
|
||||
type: subgraph
|
||||
name: Reviewer Subgraph
|
||||
description: Reviews execution via subgraph
|
||||
config:
|
||||
actor_path: examples/actors/reviewers/quality_gate.yaml
|
||||
edges:
|
||||
@@ -438,12 +444,14 @@ Feature: Actor YAML examples validation
|
||||
- id: executor
|
||||
type: agent
|
||||
name: Executor
|
||||
description: Executes main task
|
||||
config:
|
||||
model: gpt-4
|
||||
prompt: "Execute task"
|
||||
- id: verifier
|
||||
type: conditional
|
||||
name: Verifier
|
||||
description: Verifies task success or determines retry
|
||||
config:
|
||||
conditions:
|
||||
- check: "state.get('success') == True"
|
||||
@@ -455,18 +463,21 @@ Feature: Actor YAML examples validation
|
||||
- id: retry
|
||||
type: agent
|
||||
name: Retry Handler
|
||||
description: Handles retry logic
|
||||
config:
|
||||
model: gpt-4
|
||||
prompt: "Fix and retry"
|
||||
- id: success
|
||||
type: agent
|
||||
name: Success Handler
|
||||
description: Handles success case
|
||||
config:
|
||||
model: gpt-4
|
||||
prompt: "Handle success"
|
||||
- id: escalate
|
||||
type: tool
|
||||
name: Escalation
|
||||
description: Escalates to alert
|
||||
config:
|
||||
tool_name: notifications/send_alert
|
||||
edges:
|
||||
@@ -501,17 +512,20 @@ Feature: Actor YAML examples validation
|
||||
- id: strategic_planner
|
||||
type: agent
|
||||
name: Strategic Planner
|
||||
description: Creates high-level strategic plan
|
||||
config:
|
||||
model: gpt-4
|
||||
prompt: "High-level planning"
|
||||
- id: tactical_planner
|
||||
type: subgraph
|
||||
name: Tactical Planner
|
||||
description: Plans tactical execution steps
|
||||
config:
|
||||
actor_path: examples/actors/strategists/task_planner.yaml
|
||||
- id: executor_pool
|
||||
type: subgraph
|
||||
name: Executor Pool
|
||||
description: Executes tasks in parallel
|
||||
config:
|
||||
actor_path: examples/actors/executors/code_writer.yaml
|
||||
parallel: true
|
||||
@@ -519,6 +533,7 @@ Feature: Actor YAML examples validation
|
||||
- id: validator
|
||||
type: subgraph
|
||||
name: Validator
|
||||
description: Validates execution results
|
||||
config:
|
||||
actor_path: examples/actors/validators/python_checker.yaml
|
||||
edges:
|
||||
@@ -604,14 +619,19 @@ Feature: Actor YAML examples validation
|
||||
name: test/cyclic
|
||||
type: graph
|
||||
model: gpt-4
|
||||
description: Graph with cycle for testing
|
||||
route:
|
||||
nodes:
|
||||
- id: a
|
||||
type: agent
|
||||
name: Node A
|
||||
description: First node in cycle
|
||||
config:
|
||||
model: gpt-4
|
||||
- id: b
|
||||
type: agent
|
||||
name: Node B
|
||||
description: Second node in cycle
|
||||
config:
|
||||
model: gpt-4
|
||||
edges:
|
||||
|
||||
@@ -89,6 +89,13 @@ def step_then_description_contains(context: Context, expected_text: str) -> None
|
||||
assert expected_text.lower() in context.actor_config.description.lower()
|
||||
|
||||
|
||||
@then('the actor config context_view should be "{expected_view}"')
|
||||
def step_then_config_context_view_is(context: Context, expected_view: str) -> None:
|
||||
"""Verify context_view matches (with 'config' in step name)."""
|
||||
assert context.actor_config is not None
|
||||
assert context.actor_config.context_view == expected_view
|
||||
|
||||
|
||||
@then("the actor config should have read-only tools")
|
||||
def step_then_has_readonly_tools(context: Context) -> None:
|
||||
"""Verify actor has read-only tools."""
|
||||
@@ -256,14 +263,35 @@ def step_then_has_parallel_execution(context: Context) -> None:
|
||||
"""Verify route supports parallel execution."""
|
||||
assert context.actor_config is not None
|
||||
assert context.actor_config.route is not None
|
||||
# Check for nodes with parallel config or multiple edges from same node
|
||||
|
||||
# Check for two things:
|
||||
# 1. Nodes with parallel config
|
||||
# 2. Nodes with multiple outgoing edges (parallel branching)
|
||||
from collections import defaultdict
|
||||
|
||||
# Check for parallel config in subgraph nodes
|
||||
has_parallel_config = False
|
||||
for node in context.actor_config.route.nodes:
|
||||
if node.type == "subgraph" and hasattr(node, "config") and node.config:
|
||||
# Config might be a dict or an object
|
||||
if isinstance(node.config, dict):
|
||||
has_parallel_config = node.config.get("parallel", False)
|
||||
else:
|
||||
has_parallel_config = getattr(node.config, "parallel", False)
|
||||
if has_parallel_config:
|
||||
break
|
||||
|
||||
# Check for nodes with multiple outgoing edges
|
||||
edge_counts = defaultdict(int)
|
||||
for edge in context.actor_config.route.edges:
|
||||
edge_counts[edge.from_node] += 1
|
||||
# Parallel execution would have nodes with multiple outgoing edges
|
||||
assert any(count > 1 for count in edge_counts.values())
|
||||
has_multiple_edges = any(count > 1 for count in edge_counts.values())
|
||||
|
||||
# Either condition satisfies parallel execution
|
||||
assert has_parallel_config or has_multiple_edges, (
|
||||
f"Route should have parallel execution via config or multiple outgoing edges "
|
||||
f"(found parallel_config={has_parallel_config}, multiple_edges={has_multiple_edges})"
|
||||
)
|
||||
|
||||
|
||||
@then("the actor memory max_messages should be at least {minimum:d}")
|
||||
|
||||
@@ -765,9 +765,11 @@ def step_when_validate_schema(context: Context) -> None:
|
||||
data = yaml.safe_load(context.actor_yaml_string)
|
||||
context.actor_config = ActorConfigSchema.model_validate(data)
|
||||
context.validation_error = None
|
||||
context.error = None # For compatibility with service_steps
|
||||
except (ValidationError, ValueError) as e:
|
||||
context.actor_config = None
|
||||
context.validation_error = e
|
||||
context.error = e # For compatibility with service_steps
|
||||
|
||||
|
||||
@when("I validate the actor schema from file")
|
||||
@@ -776,9 +778,11 @@ def step_when_validate_from_file(context: Context) -> None:
|
||||
try:
|
||||
context.actor_config = ActorConfigSchema.from_yaml_file(context.actor_yaml_file)
|
||||
context.validation_error = None
|
||||
context.error = None # For compatibility with service_steps
|
||||
except (ValidationError, ValueError, FileNotFoundError) as e:
|
||||
context.actor_config = None
|
||||
context.validation_error = e
|
||||
context.error = e # For compatibility with service_steps
|
||||
|
||||
|
||||
@when("I save the actor to YAML file")
|
||||
@@ -804,9 +808,11 @@ def step_when_attempt_load(context: Context) -> None:
|
||||
try:
|
||||
context.actor_config = ActorConfigSchema.from_yaml_file(context.actor_yaml_file)
|
||||
context.validation_error = None
|
||||
context.error = None # For compatibility with service_steps
|
||||
except FileNotFoundError as e:
|
||||
context.actor_config = None
|
||||
context.validation_error = e
|
||||
context.error = e # For compatibility with service_steps
|
||||
|
||||
|
||||
# ────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user