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
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.
314 lines
16 KiB
Gherkin
314 lines
16 KiB
Gherkin
Feature: Agent Template Instantiation
|
|
As a developer
|
|
I want templates to instantiate agents with parameters, component references, and routing configuration
|
|
So that agent definitions can be reused and composed from template configurations
|
|
|
|
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
|