Skip to main content
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
A workflow is compiled into an 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.
Here’s what it does:
  • Accepts a single input: query
  • Runs a generation step
  • Returns a single output: response
  • Automatically displays response in 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.
This workflow enforces a disciplined research strategy—mandatory document retrieval, iterative planning, and deep dives—using a hybrid semantic-lexical search with reranking for precision, followed by a constrained generation step that produces concise, well-structured Markdown answers without meta commentary or speculation.

YAML Schema (Root-level Fields)

Every Agent Composer YAML file defines a graph with the following root fields:

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.
Example:

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

Conceptually: inputs.query → preprocess.output → finalize.response → outputs.response

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


Dynamic Configuration Overrides

config_overrides allow node configuration to be set dynamically at runtime.
The following rules apply to dynamic configuration overrides:
  • Overrides are merged with static config
  • Overrides can come from any node output
  • Nodes whose type has OUTPUTS = None cannot use config overrides

Output Node

Every graph must explicitly define how node outputs map to graph outputs.
The output node:
  • 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.).
Bear in mind the following in regards to UI streaming:
  • 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

Bear in mind the following regarding subgraphs:
  • 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.
Bear in mind the following rules regarding conditional execution:
  • 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:
  1. CreateMessageHistoryStep – Initialize structured conversation state
  2. AgenticResearchStep – Perform multi-turn research using tools
  3. GenerateFromResearchStep – Generate a final response grounded in research results

Initializing Message History

The following step converts the raw user input into a structured message_history object. This standardized message format is required by agentic steps and ensures consistent conversational context throughout the workflow.
This step:
  • Transforms the user’s query into 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.
This step:
  • 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 research output used downstream
Enabling 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.
Bear in mind the following key points:
  • Tools are defined inline using either step_config or graph_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_config graph_config

Configuring the Agent Loop

The following configuration controls how the agent reasons and how many turns it may take when performing research.
This configuration determines:
  • 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 Guidelines
The identity guidelines describe the agent’s role and grounding expectations, ensuring it behaves as a factual, retrieval-augmented assistant.
Research Guidelines
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
These instructions ensure consistent and repeatable agent behavior across runs.

Generating the Final Response

The following step synthesizes a final user-facing response using the structured research output produced by the agent. generate:
This step:
  • Consumes message_history and 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.
Response guidelines typically enforce:
  • Immediate answers with no preamble or meta-commentary
  • Clear, concise Markdown formatting
  • Explicit handling of missing or incomplete information
  • A professional and neutral tone
This ensures consistent output quality and prevents internal reasoning or research details from leaking into the final response.

End-to-End Data Flow

The overall execution flow of an agentic workflow is as follows:
Each phase has a clearly defined responsibility, making the workflow easier to understand, debug, and extend.

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:
  1. Implement a PipelineStep subclass
  2. Define INPUTS, OUTPUTS, and optional UI metadata
  3. Register it in registrations.py
  4. Add it to the step catalog for discoverability

Running Graphs Programmatically

To run graphs programmatically, use the following Python code:
Inputs map to inputs, and outputs are returned as a 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 durations
  • dynamic_agent_trace: agent reasoning and tool usage (if applicable)

Common Validation Errors

The following are common validation errors and how to fix them:

Additional Resources