> ## Documentation Index
> Fetch the complete documentation index at: https://docs.contextual.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Agentic Workflows

> Build dynamic, tool-using agents with Agent Composer

## Description

Agent Composer provides the `AgenticResearchStep` pattern for building agentic workflows that can dynamically select and execute tools. This separates research (tool use) from response generation for better control and observability.

## AgenticResearchStep Pattern

The recommended pattern for research-focused agents:

```yaml theme={null}
version: 0.1
inputs:
  query: str

outputs:
  response: str

nodes:
  create_message_history:
    type: CreateMessageHistoryStep
    input_mapping:
      query: __inputs__#query

  research:
    type: AgenticResearchStep
    ui_stream_types:
      retrievals: true
    config:
      tools_config:
        - name: search_docs
          description: |
            Search the datastore containing user-uploaded documents.
          step_config:
            type: SearchUnstructuredDataStep
            config:
              top_k: 50
              lexical_alpha: 0.1
              semantic_alpha: 0.9
              reranker: "ctxl-rerank-v2-instruct-multilingual-FP8"
              rerank_top_k: 12
              reranker_score_filter_threshold: 0.2

      agent_config:
        agent_loop:
          num_turns: 10
          parallel_tool_calls: false
          model_name_or_path: "vertex_ai/claude-sonnet-4-5@20250929"
          identity_guidelines_prompt: |
            You are a retrieval-augmented assistant created by Contextual AI.
          research_guidelines_prompt: |
            You have access to the following tool:
            - `search_docs` — Search the document datastore.

    input_mapping:
      message_history: create_message_history#message_history

  generate:
    type: GenerateFromResearchStep
    ui_stream_types:
      generation: true
    config:
      model_name_or_path: "vertex_ai/claude-sonnet-4-5@20250929"
      identity_guidelines_prompt: |
        You are a retrieval-augmented assistant created by Contextual AI.
      response_guidelines_prompt: |
        Write a concise, well-structured answer in Markdown.

    input_mapping:
      message_history: create_message_history#message_history
      research: research#research

  __outputs__:
    type: output
    input_mapping:
      response: generate#response
```

## Agent Loop Configuration

| Parameter                    | Description                                              |
| ---------------------------- | -------------------------------------------------------- |
| `num_turns`                  | Maximum number of tool-use iterations                    |
| `parallel_tool_calls`        | Whether the agent can call multiple tools simultaneously |
| `model_name_or_path`         | The LLM to use for reasoning and planning                |
| `identity_guidelines_prompt` | Defines who the agent is and its purpose                 |
| `research_guidelines_prompt` | Instructions for tool use strategy                       |

## Agent Loop Prompts

| Prompt                       | Used By                    | Description                     |
| ---------------------------- | -------------------------- | ------------------------------- |
| `identity_guidelines_prompt` | Both steps                 | Defines who the agent is        |
| `research_guidelines_prompt` | `AgenticResearchStep`      | Instructions for tool selection |
| `response_guidelines_prompt` | `GenerateFromResearchStep` | Output format instructions      |

## Example Prompts

```yaml theme={null}
identity_guidelines_prompt: |
  You are an expert research assistant specializing in technical documentation.
  You work for Acme Corp and help employees find information in internal docs.

research_guidelines_prompt: |
  Use the search_docs tool to find relevant information.
  - For factual questions, search once with precise terms
  - For complex topics, search multiple times with different queries
  - Stop searching when you have sufficient information

response_guidelines_prompt: |
  Format your response as follows:
  1. Start with a direct answer
  2. Provide supporting details with citations
  3. Use markdown formatting for readability
  4. Include a "Sources" section at the end
```

## Related

* [Tools Configuration](/reference/ac-tools-config)
* [Step Reference Catalog](/how-to-guides/ac-yaml-reference)
