forked from cleveragents/cleveragents-core
313 lines
16 KiB
Gherkin
313 lines
16 KiB
Gherkin
Feature: Agent Templates Module Coverage
|
|
As a developer
|
|
I want to test all functionality in the agent templates module
|
|
So that we achieve 90%+ code coverage for the agent_templates.py file
|
|
|
|
Background:
|
|
Given I have a clean test environment for agent templates
|
|
|
|
# AgentTemplate class tests
|
|
Scenario: Test AgentTemplate instantiate - basic agent configuration
|
|
Given I have an agent template registry
|
|
And I have a basic agent template
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the agent template
|
|
Then the agent configuration should be returned
|
|
And the parameters section should be removed from config
|
|
And template variables should be applied to the config
|
|
And the result should have correct agent structure
|
|
|
|
Scenario: Test AgentTemplate instantiate - default type assignment
|
|
Given I have an agent template registry
|
|
And I have an agent template without type
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the agent template
|
|
Then the agent type should default to llm
|
|
|
|
Scenario: Test AgentTemplate instantiate - with custom type
|
|
Given I have an agent template registry
|
|
And I have an agent template with custom type
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the agent template
|
|
Then the agent type should match the custom type
|
|
|
|
Scenario: Test AgentTemplate instantiate - parameter validation
|
|
Given I have an agent template registry
|
|
And I have an agent template with required parameters
|
|
And I have valid template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the agent template
|
|
Then parameter validation should be called
|
|
And the filled parameters should be used
|
|
|
|
Scenario: Test AgentTemplate instantiate - template variable application
|
|
Given I have an agent template registry
|
|
And I have an agent template with template variables
|
|
And I have template parameters with variable values
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the agent template
|
|
Then template variables should be replaced with parameter values
|
|
|
|
Scenario: Test AgentTemplate instantiate - deep copy behavior
|
|
Given I have an agent template registry
|
|
And I have an agent template
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the agent template
|
|
Then the original definition should not be modified for agent templates
|
|
And the returned config should be a separate copy
|
|
|
|
# CompositeAgentTemplate class tests
|
|
Scenario: Test CompositeAgentTemplate instantiate - basic composite agent
|
|
Given I have a composite agent template registry
|
|
And I have a basic composite agent template
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then a composite agent configuration should be returned
|
|
And the configuration should include components
|
|
And the configuration should include routing
|
|
And the configuration should include expose_params
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - local context creation
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then a local instantiation context should be created
|
|
And the local context should have parent context
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - parameter validation
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with required parameters
|
|
And I have valid template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then parameter validation should be called for composite
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - template variables applied to components
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with template variables in components
|
|
And I have template parameters with variable values
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then template variables should be applied to components section
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - agents from templates
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with agent templates
|
|
And I have registered agent templates
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then agent templates should be instantiated
|
|
And agents should be added to local context
|
|
And instantiated agents should be in components
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - agents direct definition
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with direct agent definitions
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then direct agent definitions should be processed
|
|
And agents should be added to local context without template lookup
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - agents with None values
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with None agent values
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then None agent values should be skipped
|
|
And no errors should occur for None agents
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - parameter merging for agents
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with agent templates and params
|
|
And I have registered agent templates
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then template parameters should be merged with agent params
|
|
And merged parameters should be passed to agent instantiation
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - graphs from templates
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with graph templates
|
|
And I have registered graph templates
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then graph templates should be instantiated
|
|
And graphs should be added to local context
|
|
And instantiated graphs should be in components
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - graphs direct definition
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with direct graph definitions
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then direct graph definitions should be processed through process_graph_definition
|
|
And graphs should be added to local context
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - graphs with None values
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with None graph values
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then None graph values should be skipped
|
|
And no errors should occur for None graphs
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - parameter merging for graphs
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with graph templates and params
|
|
And I have registered graph templates
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then template parameters should be merged with graph params
|
|
And merged parameters should be passed to graph instantiation
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - streams from templates
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with stream templates
|
|
And I have registered stream templates
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then stream templates should be instantiated
|
|
And streams should be added to local context
|
|
And instantiated streams should be in components
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - streams direct definition
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with direct stream definitions
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then direct stream definitions should be processed
|
|
And streams should be added to local context without template lookup
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - streams with None values
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with None stream values
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then None stream values should be skipped
|
|
And no errors should occur for None streams
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - parameter merging for streams
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with stream templates and params
|
|
And I have registered stream templates
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then template parameters should be merged with stream params
|
|
And merged parameters should be passed to stream instantiation
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - routing configuration
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with routing configuration
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then routing configuration should be processed
|
|
And template variables should be applied to routing
|
|
And routing should be included in final config
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - pending references resolution
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template with pending references
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then pending references should be resolved in local context
|
|
|
|
Scenario: Test CompositeAgentTemplate instantiate - missing components section
|
|
Given I have a composite agent template registry
|
|
And I have a composite agent template without components section
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I instantiate the composite agent template
|
|
Then empty components should be created
|
|
And no errors should occur for missing components
|
|
|
|
# _process_graph_definition method tests
|
|
Scenario: Test _process_graph_definition - basic graph processing
|
|
Given I have a composite agent template
|
|
And I have a graph definition
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I process the graph definition
|
|
Then template variables should be applied to graph definition
|
|
And the processed graph should be returned
|
|
|
|
Scenario: Test _process_graph_definition - with agent nodes
|
|
Given I have a composite agent template
|
|
And I have a graph definition with agent nodes
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context with registered agents
|
|
When I process the graph definition
|
|
Then agent references should be resolved
|
|
And agent_config should be added to resolved nodes
|
|
|
|
Scenario: Test _process_graph_definition - agent nodes without type
|
|
Given I have a composite agent template
|
|
And I have a graph definition with nodes without agent type
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I process the graph definition
|
|
Then non-agent nodes should not be processed for agent resolution
|
|
|
|
Scenario: Test _process_graph_definition - template variable agent references
|
|
Given I have a composite agent template
|
|
And I have a graph definition with template variable agent references
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I process the graph definition
|
|
Then template variable agent references should not be resolved as component references
|
|
|
|
Scenario: Test _process_graph_definition - unresolved agent references
|
|
Given I have a composite agent template
|
|
And I have a graph definition with unresolved agent references
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context without registered agents
|
|
When I process the graph definition
|
|
Then unresolved agent references should be handled gracefully
|
|
And no agent_config should be added for unresolved references
|
|
|
|
Scenario: Test _process_graph_definition - missing nodes section
|
|
Given I have a composite agent template
|
|
And I have a graph definition without nodes section
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I process the graph definition
|
|
Then processing should complete without errors
|
|
And no node processing should occur
|
|
|
|
Scenario: Test _process_graph_definition - None node config
|
|
Given I have a composite agent template
|
|
And I have a graph definition with None node config
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I process the graph definition
|
|
Then None node configs should be handled gracefully
|
|
And no agent resolution should occur for None nodes
|
|
|
|
Scenario: Test _process_graph_definition - empty agent reference
|
|
Given I have a composite agent template
|
|
And I have a graph definition with empty agent reference
|
|
And I have template parameters for agent templates
|
|
And I have an instantiation context for agent templates
|
|
When I process the graph definition
|
|
Then empty agent references should be handled gracefully
|
|
And no resolution should occur for empty references |