Skip to main content

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

ParameterDescription
num_turnsMaximum number of tool-use iterations
parallel_tool_callsWhether the agent can call multiple tools simultaneously
model_name_or_pathThe LLM to use for reasoning and planning
identity_guidelines_promptDefines who the agent is and its purpose
research_guidelines_promptInstructions for tool use strategy

Agent Loop Prompts

PromptUsed ByDescription
identity_guidelines_promptBoth stepsDefines who the agent is
research_guidelines_promptAgenticResearchStepInstructions for tool selection
response_guidelines_promptGenerateFromResearchStepOutput format instructions

Example Prompts

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