Skip to main content

CSV Schema Reference

AgentMap uses CSV files to define agentic AI workflows as directed graphs where autonomous agents make decisions, route intelligently, and collaborate in multi-agent systems. Each row in the CSV represents an autonomous agent node that can reason, decide, and interact with other agents. This document explains how to structure CSV files for building sophisticated agentic AI systems.

⚠️ IMPORTANT: JSON Configuration Format

AgentMap uses Python dictionary syntax for structured configuration in CSV files:

Correct: "{'provider': 'openai', 'temperature': 0.7}"
Wrong: "{"provider": "openai", "temperature": 0.7}" (breaks CSV parsing)

Why Python dict syntax?

  • CSV-friendly: No comma conflicts or escaped quotes
  • Readable: Clean and easy to edit in spreadsheets
  • Python-native: AgentMap parses these as Python literals using ast.literal_eval()
  • Tool compatible: Works perfectly with Pandas, Excel, Google Sheets

Quick Start

🚀 New to AgentMap? Start with our Quick Start Guide to build your first workflow, then return here for detailed schema reference.

Why CSV for Agentic AI?

CSV files are perfect for multi-agent systems because they:

  • Collaborative - Teams can design agent workflows together in familiar spreadsheets
  • Version Control - Track changes to agent configurations and routing logic
  • Visual - See the entire multi-agent system structure at a glance
  • Accessible - No programming required to design sophisticated agentic workflows
  • Scalable - Define complex RAG AI and LLM orchestration systems easily

CSV Columns

ColumnRequiredDescription
graph_nameYesName of the workflow graph. Multiple nodes can share the same graph_name to form a complete workflow.
NodeYesUnique identifier for this node within the graph.
next_nodeNoDirect connection to another node. Use this for simple linear flows.
ContextNoDescription or JSON configuration for the node. Can contain memory configuration.
agent_typeNoType of agent to use (e.g., "openai", "claude", "echo"). Defaults to "Default" if not specified.
next_on_successNoWhere to go on success. Can be a node name or multiple nodes with pipe separators.
next_on_failureNoWhere to go on failure. Can be a node name or multiple nodes with pipe separators.
input_fieldsNoState fields to extract as input for this agent. Pipe-separated list.
output_fieldNoField in state where this agent's output should be stored.
PromptNoText or template used by LLM agents. For some agent types, this can be configuration data. Can reference managed prompts using the prompt: notation.
DescriptionNoDetailed documentation for the node's purpose. Unlike Context (which can be used for configuration), Description is solely for documentation and does not affect functionality.

Quick Start Templates

Get started quickly with these ready-to-use CSV templates:

Field Details

Routing Fields (next_node, next_on_success, next_on_failure)

You can define routing in two ways:

  1. Using next_node for simple linear flows
  2. Using next_on_success and next_on_failure for conditional branching based on last_action_success
Routing Rule Conflict

⚠️ Important: Don't use both next_node and next_on_success/next_on_failure in the same row - this will raise an Invalidnext_nodeDefinitionError.

Use either:

  • next_node for simple linear flows
  • next_on_success/next_on_failure for conditional branching

Function References

You can use function references for advanced routing:

func:function_name

The function should be defined in the functions directory and will be called to determine the next node.

Context and Description Fields

AgentMap provides two fields for documenting and configuring nodes:

  • Context: Can contain plain text description or JSON for advanced configuration
  • Description: Purely for documentation purposes - doesn't affect functionality

Examples:

GraphA,Node1,"{'memory':{'type':'buffer'}}","This node processes user input to extract key entities",...

The Description field is useful for:

  • Documenting complex node behavior
  • Explaining the node's role in the workflow
  • Documenting expected inputs and outputs
  • Adding notes for other developers

Service Configuration for Scaffolding

Service-Aware Scaffolding

AgentMap's service-aware scaffolding system automatically detects service requirements from the Context field and generates agents with proper service integration. This dramatically accelerates custom agent development.

Service Configuration Syntax

Use the Context field to specify service requirements for custom agents that will be scaffolded:

JSON Format (Recommended):

Context
"{""services"": [""llm"", ""storage""]}"
"{""services"": [""llm"", ""vector"", ""memory""]}"
"{""services"": [""csv"", ""json"", ""file""]}"

String Format (Alternative):

Context
"services: llm|storage"
"services: vector|memory|llm"
"services: csv|json"

Supported Services

LLM Services:

  • "llm" - Multi-provider LLM service (OpenAI, Anthropic, Google)

Storage Services:

Unified Storage Architecture:

  • "storage" - Generic storage service supporting all types (CSV, JSON, File, Vector, Memory)

Separate Service Architecture:

  • "csv" - CSV file operations
  • "json" - JSON file operations
  • "file" - General file operations
  • "vector" - Vector search and embeddings
  • "memory" - In-memory data storage

Other Services:

  • "node_registry" - Access to graph node metadata for dynamic routing

Service Configuration Examples

Service Configuration Examples

⚠️ Validation Results
5 errors
Row 2, Context:JSON syntax detected. Use Python dict syntax: {'key': 'value'}
Row 3, Context:JSON syntax detected. Use Python dict syntax: {'key': 'value'}
Row 4, Context:JSON syntax detected. Use Python dict syntax: {'key': 'value'}
Row 5, Context:JSON syntax detected. Use Python dict syntax: {'key': 'value'}
Row 1, next_node:Required header 'next_node' is missing
graph_namenode_nameagent_typecontextdescriptioninput_fieldsoutput_fieldprompt
AIWorkflowAnalyzerIntelligentAnalyzer{"services": ["llm"]}AI-powered analysis agentuser_queryanalysisAnalyze: {user_query}
AIWorkflowDataProcessorDataHandler{"services": ["llm", "storage"]}Process and store dataraw_dataprocessed_dataProcess: {raw_data}
AIWorkflowSearchAgentDocumentRetriever{"services": ["vector"]}Semantic document searchsearch_queryrelevant_docsFind docs for: {search_query}
AIWorkflowRAGAgentSmartResponder{"services": ["llm", "vector", "storage"]}RAG-based response generationquestionanswerAnswer: {question}

8 columns, 4 rows

Generated Agent Structure

When you run agentmap scaffold, the system analyzes the Context field and generates agents with proper service integration:

Example: LLM + Storage Service Configuration

graph_name,node_name,agent_type,context
SmartWorkflow,DataAnalyzer,IntelligentProcessor,"{""services"": [""llm"", ""storage""]}"

Generated Agent Code:

from agentmap.agents.base_agent import BaseAgent
from agentmap.services.protocols import LLMCapableAgent, StorageCapableAgent
from typing import Dict, Any

class IntelligentProcessorAgent(BaseAgent, LLMCapableAgent, StorageCapableAgent):
"""
Generated agent with LLM and storage capabilities

Available Services:
- self.llm_service: LLM service for calling language models
- self.storage_service: Generic storage service (supports all storage types)
"""

def __init__(self):
super().__init__()
# Service attributes (automatically injected during graph building)
self.llm_service: LLMServiceProtocol = None
self.storage_service: StorageServiceProtocol = None

def process(self, inputs: Dict[str, Any]) -> Any:
# Generated foundation with service integration examples
# Ready to customize with your logic
return "Your IntelligentProcessor implementation here"

Service Architecture Selection

The scaffolding system automatically chooses the optimal service architecture:

Unified Architecture (when "storage" is requested):

Context
"{""services"": [""storage""]}"

Generates: class Agent(BaseAgent, StorageCapableAgent)

  • Single service interface for all storage types
  • Access CSV, JSON, File, Vector, Memory through one service

Separate Architecture (when specific types are requested):

Context
"{""services"": [""csv"", ""vector"", ""memory""]}"

Generates: class Agent(BaseAgent, CSVCapableAgent, VectorCapableAgent, MemoryCapableAgent)

  • Dedicated service interfaces for each type
  • Type-specific operations and optimizations

Multi-Service Agent Configuration

Comprehensive AI Agent:

graph_name,node_name,agent_type,context
AdvancedWorkflow,AIProcessor,ComprehensiveAgent,"{""services"": [""llm"", ""vector"", ""storage"", ""memory"", ""node_registry""]}"

Generated:

class ComprehensiveAgent(BaseAgent, LLMCapableAgent, VectorCapableAgent, StorageCapableAgent, MemoryCapableAgent, NodeRegistryUser):
# All service capabilities integrated
# Ready for complex multi-service workflows

Best Practices for Service Configuration

✅ Recommended:

# Clear, specific service requirements
Context
"{""services"": [""llm"", ""storage""]}"

# Multi-service for complex agents
Context
"{""services"": [""llm"", ""vector"", ""memory""]}"

# Unified storage for multiple formats
Context
"{""services"": [""storage""]}"

❌ Avoid:

# Unclear or missing service specs
Context
"some services needed"

# Redundant service combinations
Context
"{""services"": [""storage"", ""csv"", ""json""]}"

# Invalid service names
Context
"{""services"": [""unknown_service""]}"

Service Integration Workflow

  1. Design: Specify service requirements in CSV Context field
  2. Scaffold: Run agentmap scaffold to generate service-integrated agents
  3. Customize: Enhance generated agents with your specific logic
  4. Test: Validate service integration and functionality
  5. Deploy: Use compiled agents in production workflows
# Complete workflow
agentmap scaffold --graph MyWorkflow # Generate service-integrated agents
agentmap run --graph MyWorkflow # Test with generated agents
agentmap compile --graph MyWorkflow # Compile for production

input_fields and output_field

These fields control data flow between nodes:

  • input_fields: Which state values this node can access (pipe-separated)
  • output_field: Where this node's output is stored in state

Complex Routing

For complex routing patterns:

  • Function references: func:choose_next
  • Multiple targets: Use pipe-separator in next_on_success or next_on_failure

Example CSV Structure

Complete Weather Workflow Example

graph_namenode_namenext_nodecontextagent_typenext_on_successnext_on_failureinput_fieldsoutput_fieldpromptdescription
WeatherFlowGetLocationGet user locationinputFetchWeatherErrorHandlerlocationEnter the city name:Input node for weather workflow
WeatherFlowFetchWeather{'api_key': 'env:WEATHER_API'}weather_apiGenerateReportErrorHandlerlocationweather_dataFetches weather data from API
WeatherFlowGenerateReport{'provider': 'openai'}llmEndErrorHandlerweather_data|locationreportGenerate weather report for {location}Creates natural language weather report
WeatherFlowErrorHandlerHandle any errorsechoEnderrorerror_messageError handling node
WeatherFlowEndComplete workflowechoreport|error_messageoutputFinal output node

11 columns, 5 rows

Best Practices

Node Naming

  • Use descriptive node names that indicate their purpose
  • Avoid spaces and special characters
  • Use PascalCase or snake_case consistently

Graph Organization

  • Group related nodes with consistent graph_name
  • Design clear flow from start to end
  • Include error handling paths

Context Configuration

  • Use JSON format for complex configurations
  • Reference environment variables with env:VARIABLE_NAME
  • Document configuration options in Description field

Data Flow

  • Specify input_fields to control what data flows between nodes
  • Use output_field to name result storage consistently
  • Avoid overwriting important state values

Error Handling

  • Always include error handling nodes
  • Use next_on_failure to route to error handlers
  • Design graceful degradation paths

Documentation

  • Use Description field for detailed node documentation
  • Include expected inputs and outputs
  • Document any special configuration requirements

Validation Rules

Required Fields

  • graph_name: Must be non-empty string
  • Node: Must be unique within the graph

Routing Validation

  • Cannot use both next_node and next_on_success/next_on_failure in the same row
  • Raises Invalidnext_nodeDefinitionError if both are specified
  • Target nodes in routing fields must exist in the graph

Field References

  • input_fields and output_field should reference valid state keys
  • Pipe-separated lists must not contain empty values
  • Function references must follow func:function_name format

Context Validation

  • JSON in Context field must be valid JSON syntax
  • Environment variable references must use env:VARIABLE_NAME format
  • Prompt references must use prompt:template_name format

Error Handling

Common Validation Errors

Invalidnext_nodeDefinitionError

❌ Wrong: Using both next_node and next_on_success

# DON'T DO THIS
MyGraph,Node1,Next,config,agent,Success,Failure,input,output,prompt

✅ Correct: Use either next_node OR next_on_success/next_on_failure

# Option 1: Simple linear flow
MyGraph,Node1,Next,config,agent,,,input,output,prompt

# Option 2: Conditional branching
MyGraph,Node1,,config,agent,Success,Failure,input,output,prompt

Best Practices for Error Prevention

  1. Validate CSV Structure: Use agentmap validate workflow.csv before execution
  2. Test Small Graphs: Start with simple graphs and add complexity gradually
  3. Check Node References: Ensure all referenced nodes exist in the graph
  4. Validate JSON: Use a JSON validator for complex Context configurations

Common Patterns

Linear Flow

Linear Flow Pattern

graph_namenode_namenext_nodecontextagent_typenext_on_successnext_on_failureinput_fieldsoutput_fieldprompt
MyGraphStartInitial nodeinputProcessdatauser_inputEnter data:
MyGraphProcessProcess the datatransformEnduser_inputresult
MyGraphEndFinal outputechoresultoutput

10 columns, 3 rows

Conditional Branching

Conditional Branching Pattern

graph_namenode_namenext_nodecontextagent_typenext_on_successnext_on_failureinput_fieldsoutput_fieldprompt
MyGraphDecisionMake decisionbranchingSuccessFailureinputdecision
MyGraphSuccessSuccess pathechoEnddecisionsuccess_result
MyGraphFailureFailure pathechoEnddecisionfailure_result
MyGraphEndFinal outputechosuccess_result|failure_resultoutput

10 columns, 4 rows

Parallel Processing

Parallel Processing Pattern

graph_namenode_namenext_nodecontextagent_typenext_on_successnext_on_failureinput_fieldsoutput_fieldprompt
MyGraphSplitSplit workdefaultTaskA|TaskB|TaskCErrordatatasks
MyGraphTaskAProcess Aworker_aJoinErrortasksresult_a
MyGraphTaskBProcess Bworker_bJoinErrortasksresult_b
MyGraphTaskCProcess Cworker_cJoinErrortasksresult_c
MyGraphJoinCombine resultssummaryEndErrorresult_a|result_b|result_cfinal_result
MyGraphEndOutput resultsechofinal_resultoutput

10 columns, 6 rows

See Also