Introducing Virtual MCP Servers
LogoLogo
GithubJoin SlackSignupBook a Demo
  • Documentation
  • Self Hosted
  • Integrations
  • Guides
  • Enterprise
  • Introduction to AI Gateway
  • Supported Models
  • Supported MCP Servers
  • Getting Started
    • Quick Start
    • Working with API
    • Working with Multiple Agents
    • Working with MCPs
    • Working with Headers
    • User Tracking
    • Using Parameters
  • Concepts
    • Thread
    • Trace
    • Run
    • Label
    • Message
    • Virtual Models
      • Routing with Virtual Model
    • Virtual MCP Servers
  • Features
    • Tracing
    • Routing
    • MCP Support
    • Publishing MCP Servers
    • Usage
    • Analytics
    • Guardrails
    • User Roles
    • Cost Control
  • Python SDK
    • Getting Started
  • API Reference
  • Postman Collection
Powered by GitBook
LogoLogo

Social

  • LinkedIn
  • X
  • Youtube
  • Github

Platform

  • Pricing
  • Documentation
  • Blog

Company

  • Home
  • About

Legal

  • Privacy Policy
  • Terms of Service

2025 LangDB. All rights reserved.

On this page
  • What is a Multi-Agent System?
  • Why Track Workflows?

Was this helpful?

Export as PDF
  1. Getting Started

Working with Multiple Agents

Learn how to use LangDB to Trace Multi Agent workflows

PreviousWorking with APINextWorking with MCPs

Last updated 17 days ago

Was this helpful?

LangDB automatically visualizes how agents interact, providing a clear view of workflows, hierarchies, and usage patterns by adding and headers.

This allows developers to track interactions between agents seamlessly, ensuring clear visibility into workflows and dependencies.

What is a Multi-Agent System?

A multi-agent system consists of independent agents collaborating to solve complex tasks. Agents handle various roles such as user interaction, data processing, and workflow orchestration. LangDB streamlines tracking these interactions for better efficiency and transparency.

Why Track Workflows?

Tracking ensures:

  • Clear Execution Flow: Understand how agents interact.

  • Performance Optimization: Identify bottlenecks.

  • Reliability & Accountability: Improve transparency.

LangDB supports two main concepts.

  • Example

Using the same Run ID and Thread ID across multiple agents ensures seamless tracking, maintaining context across interactions and providing a complete view of the workflow

from openai import OpenAI
from uuid import uuid4
client = OpenAI(
    base_url="https://api.us-east-1.langdb.ai/{langdb_project_id}/v1"  # LangDB API base URL,
    api_key=api_key,  # Replace with your LangDB token
)
response1 = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "developer", "content": "You are a helpful assistant."},
              {"role": "user", "content": "Hello!"}],  
    extra_headers={"x-thread-id": thread_id, "x-run-id": run_id}
)

# Agent 2 processes the response
response2 = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "developer", "content": "Processing user input."},
              {"role": "user", "content": response1.choices[0].message["content"]}],  
    extra_headers={"x-thread-id": thread_id, "x-run-id": run_id}
)

: A complete end-to-end interaction between agents, grouped for easy tracking.

: Aggregate multiple Runs into a single thread for a unified chat experience.

Checkout the full Multi-Agent Tracing Example .

Run
Thread
here
run
thread
With LangDB you can trace mulitple Agents. This will be in a form of a thread which stores all the interaction of workflow as a conversation and tracing which has details about the LLMs, Tool calls, Models, Parameters, etc.