Files
cleveractors-core/features/composite_agent_coverage.feature
CoreRasurae 9753b31c7e
CI / quality (push) Successful in 36s
CI / lint (push) Successful in 38s
CI / typecheck (push) Successful in 49s
CI / security (push) Successful in 51s
CI / integration_tests (push) Successful in 55s
CI / unit_tests (push) Successful in 3m35s
CI / build (push) Successful in 33s
CI / coverage (push) Successful in 3m36s
CI / status-check (push) Successful in 3s
test: add coverage gap tests improving coverage from 81.4% to 96.90%
Add 13 BDD scenarios covering previously uncovered code paths:
- SAFE_BUILTINS validation (sandbox.py: 0% → 100%)
- ConfigurationError re-raise path (config.py: 99.3% → 100%)
- CLI hello/main functions (cli.py: 72.7% → 90.9%)
- GraphState message truncation (state.py: 98.7% → 100%)
- ProgressBarManager update/context rendering (progress.py: 0% → 87.7%)
- MessageRouter regex/exact/contains routing (message_router.py: 0% → 59.4%)
- RoutingAdapter parse_routing_command (routing_adapter.py)
- DynamicRouterNode pattern-based routing (dynamic_router.py)
- EnhancedTemplateRegistry unknown template type (enhanced_registry.py: 99.2%)
- CompositeAgent null-graph error path (composite.py: 97.8% → 98.6%)

Cover routing_adapter.py (17% → 100%): all GOTO/ROUTE patterns,
create_routing_node, create_conditional_router, dynamic config conversion.

Cover dynamic_router.py (21% → 87%): execute with empty/dict/string
messages, extract_message with colon parsing, config creation, graph
extension with edge generation.

Cover message_router.py (59% → 78%): regex, exact, contains, prefix,
suffix match types, invalid regex handling, non-string message, set_state.

Exercise Node._prepare_conversation_history with invalid configs,
_runtime error paths, _execute_message_router with rules,
_execute_agent with current_message and metadata propagation,
_execute_function with dynamic_router, and _execute_conditional
with content_contains/content_not_contains/content_starts_with
and custom condition types. Improves nodes.py from 71.3% to 72.5%.

Exercise PureGraphConfig, PureLangGraph init with dict/config,
RxPyLangGraphBridge registration/connection/lookup,
ReactiveStreamRouter operator creation and condition functions,
ReactiveConfigParser config/route/graph parsing,
ToolAgent tool execution with JSON, space-separated, single,
file_read, progress_bar invocations, and
ReactiveCleverAgentsApp init/dispose/visualization.
2026-06-02 20:02:01 +01:00

223 lines
9.5 KiB
Gherkin

Feature: Composite Agent Routing, Component Management, and Multi-Mode Processing
As a developer
I want CompositeAgent to route messages through agents, graphs, and streams, manage components, and handle missing components gracefully
So that composite agent workflows correctly dispatch messages through all supported routing types
Background:
Given I have a composite agent test environment
@composite-coverage
Scenario: Initialize CompositeAgent with basic configuration
Given I have a basic composite agent configuration
When I create a composite agent
Then the composite agent should be initialized correctly
And the agent should have empty component collections
And the agent should have default routing configuration
@composite-coverage
Scenario: Initialize CompositeAgent and reject legacy strategy configuration
Given I have a legacy strategy-based configuration
When I attempt to create a composite agent with legacy config
Then a ConfigurationError should be raised for composite agent
And the error should mention deprecated strategy-based configuration
@composite-coverage
Scenario: Add agents to composite agent
Given I have a composite agent
And I have mock child agents
When I add agents to the composite agent
Then the agents should be stored in the agents collection
And the agents should be added to components configuration
And the agents collection should contain the correct agents
@composite-coverage
Scenario: Add graphs to composite agent
Given I have a composite agent
And I have mock LangGraph instances
When I add graphs to the composite agent
Then the graphs should be stored in the graphs collection
And the graphs should be added to components configuration
And the graphs collection should contain the correct graphs
@composite-coverage
Scenario: Add streams to composite agent
Given I have a composite agent
And I have mock stream configurations
When I add streams to the composite agent
Then the streams should be stored in the streams collection
And the streams should be added to components configuration
And the streams collection should contain the correct streams
@composite-coverage
Scenario: Set parameters on composite agent
Given I have a composite agent
When I set various parameters on the agent
Then the parameters should be stored in expose_params
And the parameters should be available for propagation
@composite-coverage
Scenario: Process messages through process_message method
Given I have a composite agent with a mock child agent
When I call process_message on the composite agent
Then it should delegate to the process method
And return the same result as process
@composite-coverage
Scenario: Process messages with no routing configuration
Given I have a composite agent with agents but no routing
When I process a message through the composite agent
Then it should use the first available agent
And return the processed message
@composite-coverage
Scenario: Process messages with no routing and graphs only
Given I have a composite agent with graphs but no routing
When I process a message through the composite agent
Then it should use the first available graph
And return the processed message from graph
@composite-coverage
Scenario: Process messages with no routing and streams only
Given I have a composite agent with streams but no routing
When I process a message through the composite agent
Then it should use the first available stream
And return the processed message from stream
@composite-coverage
Scenario: Process messages with no components
Given I have a composite agent with no components
When I process a message through the composite agent
Then a ConfigurationError should be raised for composite agent
And the error should mention no components to process with
@composite-coverage
Scenario: Process messages via agent routing
Given I have a composite agent with explicit agent routing
When I process a message through the composite agent
Then it should route to the specified agent
And return the agent's processed response
@composite-coverage
Scenario: Process messages via graph routing
Given I have a composite agent with explicit graph routing
When I process a message through the composite agent
Then it should route to the specified graph
And return the graph's processed response
@composite-coverage
Scenario: Process messages via stream routing
Given I have a composite agent with explicit stream routing
When I process a message through the composite agent
Then it should route to the specified stream
And return the stream's processed response
@composite-coverage
Scenario: Process messages with unknown routing type
Given I have a composite agent with unknown routing type
When I process a message through the composite agent
Then a ConfigurationError should be raised for composite agent
And the error should mention unknown input type
@composite-coverage
Scenario: Process via agent with missing agent
Given I have a composite agent with agent routing to non-existent agent
When I process a message through the composite agent
Then an ExecutionError should be raised for composite agent
And the error should mention agent not found
@composite-coverage
Scenario: Process via graph without LangGraph bridge
Given I have a composite agent with graph routing but no bridge
When I process a message through the composite agent
Then an ExecutionError should be raised for composite agent
And the error should mention LangGraph bridge not available
@composite-coverage
Scenario: Process via graph with missing graph
Given I have a composite agent with graph routing to non-existent graph
When I process a message through the composite agent
Then an ExecutionError should be raised for composite agent
And the error should mention graph not found
@composite-coverage
Scenario: Process via graph using bridge fallback
Given I have a composite agent with LangGraph bridge
And the bridge has a graph not in local collection
When I process a message via graph routing
Then it should retrieve the graph from the bridge
And execute the graph successfully
@composite-coverage
Scenario: Process via graph with result messages
Given I have a composite agent with LangGraph that returns messages
When I process a message via graph routing
Then it should extract content from the last message
And return the message content
@composite-coverage
Scenario: Process via graph with non-message result
Given I have a composite agent with LangGraph that returns non-message result
When I process a message via graph routing
Then it should convert the result to string
And return the string representation
@composite-coverage
Scenario: Process via stream without stream router
Given I have a composite agent with stream routing but no router
When I process a message through the composite agent
Then an ExecutionError should be raised for composite agent
And the error should mention stream router not available
@composite-coverage
Scenario: Process via stream with custom output configuration
Given I have a composite agent with stream routing and custom output
When I process a message through the composite agent
Then it should subscribe to the custom output stream
And return the processed message from custom stream
@composite-coverage
Scenario: Process via stream with default output
Given I have a composite agent with stream routing and default output
When I process a message through the composite agent
Then it should subscribe to the default __output__ stream
And return the processed message
@composite-coverage
Scenario: Process via stream with message object response
Given I have a composite agent with stream that returns message objects
When I process a message through the composite agent
Then it should extract content from message object
And return the message content
@composite-coverage
Scenario: Process via stream with timeout handling
Given I have a composite agent with slow stream processing
When I process a message through the composite agent
Then it should handle timeout appropriately
And dispose of the subscription properly
@composite-coverage
Scenario: Get capabilities from composite agent with all component types
Given I have a composite agent with agents, graphs, and streams
When I get the capabilities of the composite agent
Then it should include composite capability
And it should include capabilities from all child agents
And it should include stateful-workflow for graphs
And it should include reactive-processing for streams
And it should remove duplicate capabilities
@composite-coverage
Scenario: Get capabilities from composite agent with legacy strategy
Given I have a composite agent with legacy strategy attribute
When I get the capabilities of the composite agent
Then it should include the legacy strategy capability
And it should include composite capability
@composite-coverage
Scenario: Merge context with exposed parameters
Given I have a composite agent with exposed parameters
When I process a message with additional context
Then the context should be merged with exposed parameters
And exposed parameters should take precedence
And the merged context should be used for processing