Skip to main content
Agentic Enrich stage showing multi-turn reasoning agent with tool access for document classification
The Agentic Enrich stage uses a multi-turn reasoning agent (default: Claude) that can call tools — taxonomy lookup, example search, and content analysis — to produce high-quality structured classifications for each document.
Stage Category: ENRICH (Enriches documents)Transformation: N documents → N documents (with agent-produced classification added)

When to Use

Use CaseDescription
Complex classificationAmbiguous categories requiring multi-step reasoning
Multimodal analysisVideo/image content needing perceptual analysis + reasoning
Taxonomy-aware classificationAgent looks up taxonomy definitions before deciding
Few-shot classificationAgent queries already-classified examples for reference

When NOT to Use

ScenarioRecommended Alternative
Simple single-shot extractionllm_enrich (faster, cheaper)
Vector-based taxonomy matchingtaxonomy_enrich (no LLM cost)
High-throughput batch processingllm_enrich with batch API
Deterministic field transformationjson_transform

Parameters

ParameterTypeDefaultDescription
system_promptstringRequiredSystem prompt for the reasoning agent. Supports {{INPUT.*}}, {{DOC.*}}, {{CONTEXT.*}} templates
output_schemaobjectRequiredJSON schema for the structured output the agent must produce
output_fieldstringmetadata.classificationDot-path where classification is stored on each document
providerstringanthropicLLM provider for the reasoning agent
model_namestringclaude-sonnet-4-5-20250929Model for the reasoning agent
api_keystringnullBYOK API key. Supports {{secrets.*}}
taxonomy_idstringnullTaxonomy to load via get_taxonomy_categories tool
example_collection_idsarraynullCollections to search for classified examples
analysis_providerobjectGoogle/GeminiSecondary LLM config for analyze_content tool
enabled_toolsarraynullExplicit tool list. Auto-detected when null
max_turnsinteger8Maximum agent reasoning turns (1-20)
timeout_secondsfloat60.0Max wall-clock seconds per document (5-300)
temperaturefloat0.0Sampling temperature for the agent
whenobjectnullConditional filter — only enrich matching documents
max_concurrencyinteger2Parallel agent loops (1-5)

Available Tools

The agent has access to three tools, auto-enabled based on configuration:
ToolEnabled WhenDescription
get_taxonomy_categoriestaxonomy_id is setLoads full taxonomy definition (categories, hierarchy, descriptions) from the database
query_examplesexample_collection_ids is setVector search against already-classified collections, optionally filtered by category label
analyze_contentAlways availableDelegates to a secondary LLM (default: Gemini) for specialized content analysis (video, image, audio)

Configuration Examples

{
  "stage_type": "enrich",
  "stage_id": "agentic_enrich",
  "parameters": {
    "provider": "anthropic",
    "model_name": "claude-sonnet-4-5-20250929",
    "system_prompt": "You are an expert IAB content classifier. Use the available tools to: 1) Load the IAB taxonomy categories, 2) Analyze the video content with the analyze_content tool, 3) Query for similar already-classified examples. Make your classification decision with detailed reasoning.",
    "output_schema": {
      "type": "object",
      "properties": {
        "iab_tier1": {"type": "string"},
        "iab_tier2": {"type": "string"},
        "confidence": {"type": "number"},
        "reasoning": {"type": "string"}
      },
      "required": ["iab_tier1", "confidence", "reasoning"]
    },
    "output_field": "iab_classification",
    "taxonomy_id": "tax_iab_content",
    "example_collection_ids": ["col_classified_videos"],
    "analysis_provider": {
      "provider": "google",
      "model_name": "gemini-2.5-flash"
    },
    "max_turns": 10,
    "when": {"field": "_internal.modality", "operator": "eq", "value": "video"}
  }
}

How It Works

For each document, the stage runs a multi-turn agent loop:
  1. Initialize: Agent receives the document content + system prompt + available tools
  2. Reason: Agent analyzes the document and optionally calls tools (taxonomy lookup, example search, content analysis)
  3. Observe: Tool results are fed back to the agent as context
  4. Iterate: Loop continues until the agent produces a final answer (or max_turns/timeout_seconds is reached)
  5. Output: The agent’s structured JSON response is merged into the document at output_field

Output Examples

With Taxonomy + Examples

{
  "document_id": "doc_abc123",
  "content": "A product review video discussing...",
  "iab_classification": {
    "iab_tier1": "Technology & Computing",
    "iab_tier2": "Consumer Electronics",
    "confidence": 0.92,
    "reasoning": "The video discusses smartphone features and pricing. Taxonomy lookup confirmed 'Consumer Electronics' under 'Technology & Computing'. Similar classified videos (col_classified_videos) showed consistent T&C categorization for product review content."
  }
}

Simple Classification

{
  "document_id": "doc_def456",
  "content": "Introduction to machine learning algorithms...",
  "metadata": {
    "classification": {
      "category": "Artificial Intelligence",
      "confidence": 0.88,
      "reasoning": "Document covers supervised and unsupervised learning methods, neural network architectures, and model evaluation."
    }
  }
}

Conditional Skip (When Condition)

{
  "document_id": "doc_ghi789",
  "_internal": {"modality": "text"},
  "content": "Plain text document...",
  "iab_classification": null
}
Documents that don’t match the when condition are passed through unchanged.

Performance

MetricValue
Latency2-30s per document (depends on turns and tools)
LLM calls3-15 per document
Max documents10 per execution
ParallelUp to max_concurrency (default 2)
Agentic enrichment makes multiple LLM calls per document. Use the when condition to limit which documents are processed, and keep max_turns low for simple tasks.

Common Pipeline Patterns

Search + Agentic Classify + Filter

[
  {
    "stage_type": "filter",
    "stage_id": "feature_search",
    "parameters": {
      "searches": [
        {
          "feature_uri": "mixpeek://multimodal_extractor@v1/vertex_multimodal_embedding",
          "query": "{{INPUT.query}}",
          "top_k": 20
        }
      ],
      "final_top_k": 20
    }
  },
  {
    "stage_type": "enrich",
    "stage_id": "agentic_enrich",
    "parameters": {
      "system_prompt": "Classify this content by IAB category using the taxonomy and examples.",
      "output_schema": {
        "type": "object",
        "properties": {
          "iab_category": {"type": "string"},
          "confidence": {"type": "number"}
        }
      },
      "output_field": "classification",
      "taxonomy_id": "tax_iab",
      "example_collection_ids": ["col_labeled"],
      "max_turns": 6
    }
  },
  {
    "stage_type": "filter",
    "stage_id": "attribute_filter",
    "parameters": {
      "field": "classification.confidence",
      "operator": "gte",
      "value": 0.8
    }
  }
]

Multimodal Analysis Pipeline

[
  {
    "stage_type": "filter",
    "stage_id": "feature_search",
    "parameters": {
      "searches": [
        {
          "feature_uri": "mixpeek://multimodal_extractor@v1/vertex_multimodal_embedding",
          "query": "{{INPUT.query}}",
          "top_k": 10
        }
      ],
      "final_top_k": 10
    }
  },
  {
    "stage_type": "enrich",
    "stage_id": "agentic_enrich",
    "parameters": {
      "system_prompt": "Use the analyze_content tool to examine this media, then classify by topic and sentiment.",
      "output_schema": {
        "type": "object",
        "properties": {
          "topic": {"type": "string"},
          "sentiment": {"type": "string", "enum": ["positive", "neutral", "negative"]},
          "summary": {"type": "string"}
        }
      },
      "output_field": "media_analysis",
      "analysis_provider": {
        "provider": "google",
        "model_name": "gemini-2.5-flash"
      },
      "max_turns": 5
    }
  },
  {
    "stage_type": "sort",
    "stage_id": "rerank",
    "parameters": {
      "inference_name": "baai_bge_reranker_v2_m3",
      "query": "{{INPUT.query}}",
      "document_field": "content"
    }
  }
]

Bring Your Own Key (BYOK)

Use your own LLM API keys instead of Mixpeek’s default keys for both the reasoning agent and the analysis provider.
1

Store your API keys as secrets

curl -X POST "https://api.mixpeek.com/v1/organizations/secrets" \
  -H "Authorization: Bearer YOUR_MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "secret_name": "anthropic_api_key",
    "secret_value": "sk-ant-..."
  }'
2

Reference secrets in your stage config

{
  "stage_type": "enrich",
  "stage_id": "agentic_enrich",
  "parameters": {
    "provider": "anthropic",
    "model_name": "claude-sonnet-4-5-20250929",
    "api_key": "{{secrets.anthropic_api_key}}",
    "system_prompt": "Classify this content.",
    "output_schema": {"type": "object", "properties": {"category": {"type": "string"}}},
    "analysis_provider": {
      "provider": "google",
      "model_name": "gemini-2.5-flash",
      "api_key": "{{secrets.google_api_key}}"
    }
  }
}
When api_key is not specified, the stage uses Mixpeek’s default API keys and usage is charged to your Mixpeek account.

Stage Metadata

The stage returns execution metadata for observability:
FieldDescription
documents_enrichedNumber of documents processed by the agent
documents_skippedNumber of documents skipped (when condition)
total_costTotal LLM API cost across all documents
total_tokens_inputTotal input tokens consumed
total_tokens_outputTotal output tokens generated
reasoning_tracesPer-document traces with tool calls and turn history
conditionalWhether a when condition was applied

Error Handling

ErrorBehavior
Agent timeoutReturns best result so far, or null
Max turns reachedLoop ends; latest structured output used
Schema validation failRaw text stored in output_field
Tool execution errorError message returned to agent; it can retry or skip
Missing system_promptStage fails with validation error
Invalid taxonomy_idget_taxonomy_categories tool returns error to agent
Empty contentAgent receives empty document; classification based on metadata
Invalid API keyError returned with auth failure

Cost Considerations

SettingCost Impact
max_turns: 3Low — simple direct classification
max_turns: 10Medium — multi-tool research workflow
max_concurrency: 1Sequential, slower but controlled cost
when conditionSkip documents that don’t need classification
timeout_seconds: 30Cap per-document spend
Start with max_turns: 3 and increase only if the agent consistently needs more iterations. Most straightforward classifications finish in 2-4 turns.
  • LLM Enrich — Single-shot LLM enrichment (faster, cheaper)
  • Taxonomy Enrich — Vector-based taxonomy matching (no LLM cost)
  • Agent Search — Multi-turn agent for search (different use case)