Files
cleveragents-core/tests/features/composite_agent_coverage.feature

222 lines
9.4 KiB
Gherkin

Feature: Composite Agent Comprehensive Coverage
As a developer
I want comprehensive test coverage of the CompositeAgent class
So that all code paths and error conditions are validated
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