Skip to main content

Service Reference

Quick reference for all AgentMap services, organized by category with context parameters and implementation details.

AgentMap Service Catalog

Browse all available services with context parameters and usage examples

⚙️ Core

GraphBuilderService

Builds graph models from CSV files and pandas DataFrames with comprehensive validation.

Dependencies:CSVGraphParserServiceLoggingService
Key Methods:build_from_csv()build_from_dataframe()
Context Parameters:csv_pathgraph_name
Protocols:GraphBuilderProtocol
Usage Example:
graph_builder = container.graph_builder_service()
graph = graph_builder.build_from_csv(Path("workflow.csv"))
⚙️ Core

CompilationService

Compiles graph models into executable LangGraph StateGraphs with state schema support.

Dependencies:GraphAssemblyServiceGraphBuilderServiceGraphBundleServiceLoggingService
Key Methods:compile_graph()compile_from_model()
Context Parameters:state_schemacsv_path
Protocols:CompilationProtocol
Usage Example:
compilation = container.compilation_service()
compiled = compilation.compile_graph("MyWorkflow", Path("workflow.csv"))
⚙️ Core

GraphRunnerService

Orchestrates graph execution with comprehensive tracking, policy evaluation, and state management.

Dependencies:CompilationServiceExecutionTrackingServiceExecutionPolicyServiceStateAdapterServiceLoggingService
Key Methods:run_graph()run_compiled_graph()
Context Parameters:initial_statetracking_enabled
Protocols:GraphRunnerProtocol
Usage Example:
runner = container.graph_runner_service()
result = runner.run_graph("MyWorkflow", {"input": "data"})
print(f"Success: {result.success}, Duration: {result.duration}s")
⚙️ Core

OrchestratorService

Provides intelligent node selection and workflow routing with multiple matching strategies.

Dependencies:PromptManagerServiceLoggingServiceLLMServiceProtocol (optional)
Key Methods:select_best_node()parse_node_keywords()
Context Parameters:strategyconfidence_thresholdnode_filterllm_config
Protocols:OrchestratorProtocol
Usage Example:
orchestrator = container.orchestrator_service()
selected = orchestrator.select_best_node(
    "I need to process a payment",
    nodes_dict, strategy="tiered", confidence_threshold=0.8
)
⚙️ Core

AgentFactoryService

Creates and configures agent instances with automatic dependency injection based on protocols.

Dependencies:AgentRegistryServiceLoggingServiceLLMService (optional)StorageManagerNodeRegistryService
Key Methods:create_agent()create_agent_by_type()
Context Parameters:agent_typecontext_config
Protocols:AgentFactoryProtocol
Usage Example:
factory = container.agent_factory_service()
agent = factory.create_agent(node)
# Agent has all required services automatically injected
⚙️ Core

GraphAssemblyService

Assembles graph models into LangGraph StateGraphs with agent integration and state schema support.

Dependencies:AgentFactoryServiceFunctionResolutionServiceStateAdapterServiceLoggingService
Key Methods:assemble_graph()assemble_with_agents()
Context Parameters:state_schemaagents_config
Protocols:GraphAssemblyProtocol
Usage Example:
assembly = container.graph_assembly_service()
state_graph = assembly.assemble_graph(graph_model, StateSchema)
compiled = state_graph.compile()
🏗️ Infrastructure

LoggingService

Provides structured logging throughout the application with class-specific and agent-specific loggers.

Dependencies:
Key Methods:get_class_logger()get_agent_logger()set_level()
Context Parameters:log_levellog_format
Protocols:LoggingServiceProtocol
Usage Example:
class MyService:
    def __init__(self, logging_service: LoggingService):
        self.logger = logging_service.get_class_logger(self)
        self.logger.info("Service initialized")
🏗️ Infrastructure

StateAdapterService

Adapts state between different formats including dictionaries, Pydantic models, and custom schemas.

Dependencies:LoggingService
Key Methods:adapt_initial_state()extract_value()
Context Parameters:schema_typevalidation_mode
Protocols:StateAdapterProtocol
Usage Example:
adapter = container.state_adapter_service()
adapted = adapter.adapt_initial_state({"input": "data"}, StateSchema)
🏗️ Infrastructure

FunctionResolutionService

Resolves function references for dynamic routing and custom workflow logic.

Dependencies:LoggingService
Key Methods:resolve_function()register_function()
Context Parameters:function_registryresolution_scope
Protocols:FunctionResolutionProtocol
Usage Example:
resolver = container.function_resolution_service()
router_func = resolver.resolve_function("func:custom_router")
⚙️ Configuration

AppConfigService

Manages application configuration with intelligent defaults and environment-based overrides.

Dependencies:ConfigService
Key Methods:get_csv_path()get_llm_config()get_prompts_config()
Context Parameters:providerenvironment
Protocols:AppConfigProtocol
Usage Example:
config = container.app_config_service()
csv_path = config.get_csv_path()
openai_config = config.get_llm_config("openai")
⚙️ Configuration

StorageConfigService

Manages storage service configuration with provider-specific settings and defaults.

Dependencies:ConfigService
Key Methods:get_provider_config()get_default_provider()
Context Parameters:storage_typeproviderconnection_params
Protocols:StorageConfigProtocol
Usage Example:
storage_config = container.storage_config_service()
csv_config = storage_config.get_provider_config("csv", "local")
💾 Storage

StorageManager

Unified interface managing all storage services with automatic provider selection and registration.

Dependencies:StorageConfigServiceVarious storage implementations
Key Methods:get_service()register_service()
Context Parameters:storage_typeproviderconnection_config
Protocols:StorageManagerProtocol
Usage Example:
storage_manager = container.storage_manager()
csv_service = storage_manager.get_service("csv")
json_service = storage_manager.get_service("json", "cloud")
💾 Storage

CSVStorageService

High-performance CSV file operations with pandas integration and flexible data format support.

Dependencies:StorageConfigServiceLoggingService
Key Methods:read()write()query()
Context Parameters:formatencodingdelimiterid_field
Protocols:StorageServiceProtocolCSVCapableProtocol
Usage Example:
csv_service = storage_manager.get_service("csv")
data = csv_service.read("users", format="records")
result = csv_service.write("users", new_data, mode="append")
💾 Storage

JSONStorageService

JSON document storage with path-based queries and structured data management.

Dependencies:StorageConfigServiceLoggingService
Key Methods:read()write()query_path()
Context Parameters:indentencodingvalidation_schema
Protocols:StorageServiceProtocolJSONCapableProtocol
Usage Example:
json_service = storage_manager.get_service("json")
doc = json_service.read("configs", "app_config")
result = json_service.write("configs", {"debug": True}, "app_config")
Validation

ValidationService

Comprehensive validation orchestration for CSV files, configurations, and data integrity.

Dependencies:CSVValidationServiceConfigValidationServiceValidationCacheServiceLoggingService
Key Methods:validate_csv()validate_config()validate_data()
Context Parameters:validation_levelcache_enabledstrict_mode
Protocols:ValidationServiceProtocol
Usage Example:
validator = container.validation_service()
result = validator.validate_csv(Path("workflow.csv"))
if not result.is_valid:
    for error in result.errors:
        print(f"Error: {error.message}")
🚀 Execution

ExecutionTrackingService

Comprehensive workflow execution tracking with metrics, history, and performance analysis.

Dependencies:AppConfigServiceLoggingService
Key Methods:create_tracker()get_tracking_enabled()get_metrics()
Context Parameters:tracking_enabledmetrics_levelhistory_retention
Protocols:ExecutionTrackingProtocol
Usage Example:
tracking = container.execution_tracking_service()
tracker = tracking.create_tracker("MyWorkflow")
tracker.start()
# ... execution ...
tracker.complete(final_state)
summary = tracker.get_summary()
🚀 Execution

ExecutionPolicyService

Configurable execution success evaluation with customizable policies and criteria.

Dependencies:AppConfigServiceLoggingService
Key Methods:evaluate_success()get_policy_type()configure_policy()
Context Parameters:policy_typesuccess_criteriafailure_tolerance
Protocols:ExecutionPolicyProtocol
Usage Example:
policy = container.execution_policy_service()
success = policy.evaluate_success(execution_summary, "MyWorkflow")
print(f"Workflow success: {success}")

Service Categories

Core Services

Essential business logic services that form the backbone of AgentMap workflows.

Infrastructure Services

Technical services providing logging, state management, and system utilities.

Configuration Services

Services managing application and storage configuration with smart defaults.

Storage Services

Data persistence services supporting multiple storage types and formats.

Validation Services

Services ensuring data integrity and configuration correctness.

Execution Services

Services tracking and managing workflow execution with policy evaluation.

Context Parameter Usage

All services accept context parameters in Python dictionary format:

context = {
'provider': 'openai',
'model': 'gpt-4',
'temperature': 0.7
}

When using services in CSV workflows, context should be specified as JSON:

name,description,type,context
llm_node,Generate response,llm,"{\"provider\": \"openai\", \"model\": \"gpt-4\"}"

Service Integration

Services integrate through dependency injection in the DI container:

# Services are automatically injected based on protocols
container = Container()
graph_runner = container.graph_runner_service()
# GraphRunnerService has CompilationService, ExecutionTrackingService, etc. injected

Protocol Implementation

Services implement specific protocols to define their capabilities:

  • LLMServiceProtocol: Language model integration
  • StorageServiceProtocol: Data persistence operations
  • LoggingServiceProtocol: Structured logging functionality
  • ValidationServiceProtocol: Data validation operations

Common Usage Patterns

1. Graph Building and Execution

# Build graph from CSV
graph_builder = container.graph_builder_service()
graph = graph_builder.build_from_csv(Path("workflow.csv"))

# Run with tracking
runner = container.graph_runner_service()
result = runner.run_graph("MyWorkflow", {'input': 'data'})

2. Storage Operations

# Get storage service
storage_manager = container.storage_manager()
csv_service = storage_manager.get_service("csv")

# Read/write data
data = csv_service.read("users", format="records")
result = csv_service.write("users", new_data)

3. Configuration Management

# Get configuration
config = container.app_config_service()
csv_path = config.get_csv_path()
llm_config = config.get_llm_config("openai")

4. Validation

# Validate CSV files
validator = container.validation_service()
result = validator.validate_csv(Path("workflow.csv"))
if not result.is_valid:
for error in result.errors:
print(f"Error: {error.message}")

Error Handling

Services follow consistent error handling patterns:

  • Graceful Degradation: Optional services return None if unavailable
  • Clear Error Messages: ValidationResult objects with detailed error information
  • Logging Integration: All errors are properly logged with context
  • Type Safety: Strong typing prevents common configuration errors

Service Lifecycle

  1. Lazy Creation: Services created when first requested from container
  2. Singleton Pattern: Services cached for reuse within container scope
  3. Dependency Injection: All dependencies automatically resolved
  4. Optional Services: LLM and external services handle missing configuration gracefully

Best Practices

  1. Always use DI container - Never instantiate services directly
  2. Check for None returns - Optional services may not be available
  3. Use proper typing - Leverage type hints for better IDE support
  4. Handle validation errors - Always check ValidationResult objects
  5. Use context parameters - Configure services through context when possible

Adding Custom Services

To extend AgentMap with custom services:

  1. Create service class with proper constructor injection
  2. Implement relevant protocols for capability declaration
  3. Register in DI container with dependency resolution
  4. Add to documentation following the patterns shown above
  5. Write comprehensive tests using the real DI container

Example custom service:

class CustomAnalyticsService:
def __init__(self, storage_manager: StorageManager,
logging_service: LoggingService):
self.storage = storage_manager
self.logger = logging_service.get_class_logger(self)

def track_event(self, event: str, data: Dict[str, Any]) -> bool:
self.logger.info(f"Tracking event: {event}")
# Implementation here
return True

# Register in container
class Container:
def custom_analytics_service(self) -> CustomAnalyticsService:
return self._get_or_create('_custom_analytics_service',
lambda: CustomAnalyticsService(
storage_manager=self.storage_manager(),
logging_service=self.logging_service()
)
)