Custom Agent Composer YAML workflows are available in public preview for enterprise users. Template agents (Basic Search and Agentic Search) are available for self-serve users, but creating custom workflows with YAML requires enterprise access. For more information or to request access, please contact your Contextual AI representative.
Overview
The Agent Composer YAML lets you define executable agent workflows as graphs. Each workflow describes:- What inputs it accepts,
- How data flows between steps (nodes),
- What outputs it produces,
- What is surfaced to the UI
ExecutableGraph and run via the /query/acl API.
The following resources can also aid you in building Agent Composer workflows via YAML:
A Minimal Workflow Example
The following is the smallest useful Agent Composer YAML. You can copy/paste this and run it immediately.- Accepts a single input:
query - Runs a generation step
- Returns a single output:
response - Automatically displays
responsein the UI
An Extended Workflow Example
The following workflow defines a retrieval-augmented question-answering pipeline that takes a user query, builds conversational context, performs structured agentic research over a vectorized document datastore, and generates a grounded response strictly based on retrieved evidence.YAML Schema (Root-level Fields)
Every Agent Composer YAML file defines agraph with the following root fields:
| Field | Required | Description |
|---|---|---|
inputs | ✅ | Graph inputs and their Python types |
outputs | ✅ | Graph outputs (must be JSON-serializable) |
nodes | ✅ | Nodes and their connections |
ui_output | ⚠️ | Required only if there are multiple outputs |
Important Constraints
- The root graph currently accepts only one input:
query: str(unless the graph is used as a subgraph). - Graph outputs must be JSON-serializable, as they are returned by the API.
- If more than one output exists, exactly one must be selected as
ui_output.
Wiring & Mapping Syntax
Nodes are connected using output references of the form:Special Nodes
__inputs__Represents graph inputs defined under inputs.__outputs__Explicitly maps node outputs to graph outputs.
Example Wiring
Nodes
A node represents a single operation in the graph with the following standard structure:Node Fields
type(required): The step type (must be registered in the system).input_mapping(required if inputs exist): Wires node inputs to outputs from other nodes.config(optional): Static configuration passed at graph construction time.config_overrides(optional): Dynamic configuration resolved at execution time.ui_stream_types(optional): Controls what this node streams to the UI.
All declared inputs of a node must be connected, or graph validation will fail.
Node Types
| Node Type | Steps |
|---|---|
| Primitive | InputNode, OutputNode, ConditionalStep, PassThroughStep, GetMemberStep, SetMemberStep, ConstantStep, WrapStep, JSONCreatorStep, IsFirstTurnStep, SliceStep, LengthStep, IndexStep, AppendStep, ConcatenateStep, MergeStep, MergeRetrievalsStep, DeleteMemberStep |
| Retrieval | FileAnalysisInputStep, ContextualAgentStep, SearchStructuredDataStep, SearchUnstructuredDataStep, QueryStructuredDatastoreStep, GetStructuredDatastoreSchemaStep, ReformulateQueryStep, MetadataSearchStep |
| Tool | WebSearchStep, CodeExecutionStep, MCPClientStep, SalesforceSOSLStep |
| Utilities | LanguageModelStep, WebhookStep, CreateMessageHistoryStep |
| Agent | AgenticResearchStep, GenerateFromResearchStep |
| generation | ResponseGenerationStep, ResponseGenFromResearchStep, PreHookStep, PostHookStep |
Dynamic Configuration Overrides
config_overrides allow node configuration to be set dynamically at runtime.
- Overrides are merged with static
config - Overrides can come from any node output
- Nodes whose type has
OUTPUTS = Nonecannot use config overrides
Output Node
Every graph must explicitly define how node outputs map to graph outputs.- Has no config
- Has no outputs of its own
- Only maps values into graph outputs
UI Streaming
Some nodes can stream events to the UI (retrievals, generation, etc.).- Each step type declares supported stream types and defaults
- Multiple nodes may stream the same type
- Streaming is independent of the final
ui_output
Subgraphs
Subgraphs are reusable workflows that can be embedded as nodes in other graphs. You can think of a subgraph like a function:- inputs = parameters
- outputs = return values
- nodes = function body
Defining a Subgraph
Using a Subgraph
- Subgraphs can be nested
- Subgraphs can be reused multiple times
- Subgraphs have isolated input/output scopes
Conditional Execution
Conditional nodes execute exactly one branch based on a condition.- Conditions are evaluated top-to-bottom
- First matching branch is executed
__inputs__inside a branch refers to conditional inputs, not graph inputs
Agentic Research & Tool Usage
Agentic behavior in Agent Composer is implemented using explicit agentic steps that separate research (tool use and planning) from final response generation. This pattern makes agent workflows easier to reason about, debug, and control, while ensuring responses remain grounded in retrieved information. A typical agentic workflow consists of three phases:CreateMessageHistoryStep– Initialize structured conversation stateAgenticResearchStep– Perform multi-turn research using toolsGenerateFromResearchStep– Generate a final response grounded in research results
Initializing Message History
The following step converts the raw user input into a structuredmessage_history object. This standardized message format is required by agentic steps and ensures consistent conversational context throughout the workflow.
- Transforms the user’s
queryinto a structured message format - Establishes a consistent conversation state
- Produces
message_history, which is reused by both research and generation steps
Agentic Research Step
The following step runs an internal agent loop that plans, executes, and adapts retrieval strategies over multiple turns. It is responsible for all tool usage and information gathering.- Controls the agent’s reasoning and decision-making process
- Determines when and how tools are invoked
- Iteratively retrieves information until sufficient coverage is achieved
- Produces a structured
researchoutput used downstream
retrievals streaming allows retrieved documents and search activity to be surfaced in the UI.
Defining Tools for the Agent
The following configuration defines tools that the agent may use during research. Each tool wraps a standard step or subgraph and is exposed to the agent as a callable capability.- Tools are defined inline using either
step_configorgraph_config - Each tool encapsulates a retrieval or processing capability
- Tool inputs must use basic Python types
- Tool outputs are returned to the agent as structured retrieval results
- Exactly one of the following must be provided for each tool:
step_configgraph_config
Configuring the Agent Loop
The following configuration controls how the agent reasons and how many turns it may take when performing research.- The maximum number of reasoning and tool-use iterations
- Whether the agent can invoke multiple tools in parallel
- The model used for agent planning and decision-making
Guiding Agent Behavior with Prompts
The following prompts define who the agent is and how it should conduct research. These prompts guide internal reasoning and are not exposed to the user.
Identity GuidelinesThe identity guidelines describe the agent’s role and grounding expectations, ensuring it behaves as a factual, retrieval-augmented assistant.
The research guidelines define the agent’s strategy, including:
- Mandatory use of retrieval tools before answering
- A breadth-first, then depth-first research approach
- Explicit planning between retrieval phases
- Adaptive execution based on retrieved content
- Efficiency constraints without sacrificing completeness
Generating the Final Response
The following step synthesizes a final user-facing response using the structured research output produced by the agent. generate:- Consumes
message_historyand research - Produces the final response returned by the graph
- Ensures the answer is grounded strictly in retrieved information
- Enabling generation streaming allows partial responses to be shown in the UI as they are produced.
Controlling Response Style and Grounding
The response configuration enforces formatting, tone, and grounding constraints for the final output.- Immediate answers with no preamble or meta-commentary
- Clear, concise Markdown formatting
- Explicit handling of missing or incomplete information
- A professional and neutral tone
End-to-End Data Flow
The overall execution flow of an agentic workflow is as follows:Design Principles
The agentic research pattern in Agent Composer is guided by a small set of core design principles. These principles ensure agent workflows remain understandable, reliable, and easy to operate as they grow in complexity.- Separation of concerns: research and generation are handled by different steps
- Grounded responses: final answers are derived only from retrieved content
- Observability: retrievals and generation can be streamed independently
- Determinism: agent behavior is fully specified by configuration
Creating New Steps
To add a new step:- Implement a
PipelineStepsubclass - Define
INPUTS,OUTPUTS, and optional UI metadata - Register it in
registrations.py - Add it to the step catalog for discoverability
Running Graphs Programmatically
To run graphs programmatically, use the following Python code:dict.
API Response
Agent Composer (AC) workflows are executed via/query/acl, with the following response fields returned:
outputs:graph outputs (JSON-serializable)workflow_trace:executed nodes and durationsdynamic_agent_trace:agent reasoning and tool usage (if applicable)
Common Validation Errors
The following are common validation errors and how to fix them:| Validation Error | Fix |
|---|---|
| Unsupplied node inputs | Ensure every required input is mapped. |
Missing __outputs__ node | Explicitly map node outputs to graph outputs. |
Multiple outputs without ui_output | Designate exactly one UI output. |
| Non-serializable outputs | Convert outputs to basic types before output. |