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

105 lines
5.0 KiB
Gherkin

Feature: Chain Agent Comprehensive Coverage
As a developer
I want to test all chain agent functionality comprehensively
So that chain.py achieves 90%+ code coverage
Background:
Given the chain agent test environment is initialized
Scenario: Create chain agent with minimal configuration
Given I have a minimal chain agent configuration with name "test_chain"
When I create a chain agent from the configuration
Then the chain agent should be created successfully
And the chain agent name should be "test_chain"
And the chain agent steps should be empty
Scenario: Create chain agent with steps configuration
Given I have a chain agent configuration with steps:
| step_name |
| validate |
| transform |
| output |
When I create a chain agent from the configuration
Then the chain agent should be created successfully
And the chain agent should have 3 steps
Scenario: Create chain agent with inline prompt
Given I have a chain agent configuration with prompt "Process this: {message}"
When I create a chain agent from the configuration
Then the chain agent should be created successfully
And the chain agent prompt template should be "Process this: {message}"
Scenario: Create chain agent with prompt reference
Given I have a template store with a template "chain_prompt"
And I have a chain agent configuration with prompt_reference "chain_prompt"
When I create a chain agent from the configuration
Then the chain agent should be created successfully
And the chain agent should use the referenced template
Scenario: Create chain agent with both prompt and prompt_reference raises error
Given I have a chain agent configuration with both prompt and prompt_reference
When I try to create a chain agent from the configuration
Then a ConfigurationError should be raised with message containing "cannot contain both"
Scenario: Process message with basic chain agent
Given I have a chain agent with no prompt and no steps
When I process the message "Hello world"
Then the chain result should be "ChainAgent processed: Hello world"
Scenario: Process message with chain agent having steps
Given I have a chain agent with steps ["step1", "step2", "step3"]
When I process the message "Start"
Then the chain result should be "ChainAgent processed: Start -> step1 -> step2 -> step3"
Scenario: Process message with inline prompt template
Given I have a chain agent with prompt "Processed: {message}"
When I process the message "Test input"
Then the prompt should be rendered with message "Test input"
And the chain result should contain "ChainAgent processed: Processed: Test input"
Scenario: Process message with inline prompt template and context
Given I have a chain agent with prompt "User {user}: {message}"
When I process the message "Hello" with context {"user": "Alice"}
Then the prompt should be rendered with context
And the chain result should contain "ChainAgent processed: User Alice: Hello"
Scenario: Process message with prompt template and steps
Given I have a chain agent with prompt "{message}!" and steps ["transform", "validate"]
When I process the message "Process"
Then the chain result should be "ChainAgent processed: Process! -> transform -> validate"
Scenario: Process message with prompt reference template
Given I have a template store with template "ref_prompt" containing "REF: {message}"
And I have a chain agent using prompt_reference "ref_prompt"
When I process the message "Referenced"
Then the chain result should contain "ChainAgent processed: REF: Referenced"
Scenario: Process message preserves existing context message key
Given I have a chain agent with prompt "Context says: {message}"
When I process the message "Override" with context {"message": "Original"}
Then the context message should be set to "Original"
And the chain result should contain "Context says: Original"
Scenario: Process message sets message key when not in context
Given I have a chain agent with prompt "New message: {message}"
When I process the message "Fresh" with context {"user": "Bob"}
Then the context message should be set to "Fresh"
And the chain result should contain "ChainAgent processed: New message: Fresh"
Scenario: Get chain agent capabilities
Given I have any chain agent
When I get the agent capabilities
Then the capabilities should be ["chain-processing"]
Scenario: Chain agent inheritance from base Agent
Given I have a chain agent instance
When I check the agent inheritance
Then the agent should be an instance of Agent base class
And the agent should have name attribute
And the agent should have config attribute
And the agent should have template_renderer attribute
Scenario: Process method delegates to process_message
Given I have a chain agent with no prompt and no steps
When I call the process method directly with "Test message"
Then the chain result should be "ChainAgent processed: Test message"