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

# Agent Orchestration Overview

> Build complex multi-agent orchestrations with prompt-based configuration - no code required

# Agent Orchestration Overview

## 🎯 What is Agent Orchestration?

**Agent Orchestration** is how Junis coordinates multiple AI agents into one working team: an orchestrator receives every request, routes it to the right specialized agent or workflow (Sequential, Parallel, or Loop), and streams the result back. In Junis, orchestration is **entirely prompt-based** — you configure agent behavior through system prompts in the Admin UI, without writing any code.

Orchestration also reaches **beyond a single team**: with [Squad Collaboration](/guides/orchestration/squad-collaboration), one squad's orchestrator can ask another squad a question mid-conversation and relay the answer back.

***

## 🏗️ Architecture

```
┌─────────────────────────────────────────────┐
│           User Request                       │
└──────────────┬──────────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────────┐
│         Orchestrator Agent                   │
│  (Analyzes & routes to appropriate agent)   │
└──┬──────────┬──────────┬────────────────────┘
   │          │          │
   ▼          ▼          ▼
┌─────┐   ┌─────┐   ┌─────────┐
│Agent│   │Agent│   │Workflow │
│  A  │   │  B  │   │ (Multi) │
└─────┘   └─────┘   └────┬────┘
                          │
                   ┌──────┴──────┐
                   ▼             ▼
                ┌─────┐       ┌─────┐
                │Agent│       │Agent│
                │  C  │       │  D  │
                └─────┘       └─────┘
```

***

## 🧩 Key Components

### 1. Orchestrator

**Role**: Top-level router that receives user requests and delegates to appropriate agents.

**Configuration**: System prompt with routing rules.

**Example**:

* User: "Send an email to John"
* Orchestrator: Routes to `EmailAgent`

### 2. Sub-Agents

**Role**: Specialized agents that handle specific tasks.

**Types**:

* **LLM Agent**: Single AI task execution
* **Sequential Agent**: Multi-step workflow (A → B → C)
* **Parallel Agent**: Concurrent execution (A + B + C simultaneously)
* **Loop Agent**: Iterative refinement

**Example**:

* `EmailAgent`: Handles email composition and sending
* `DataAgent`: Handles data retrieval and analysis

### 3. Tools & MCP

**Role**: External capabilities agents can use.

**Tools**: Python functions (e.g., `search_database`, `generate_pdf`)
**MCP**: External platform integrations (e.g., GitHub, Firecrawl)

**Example**:

* Agent calls `search_github_repo` tool → Code retrieved via GitHub MCP

### 4. RAG Knowledge Base

**Role**: Domain-specific knowledge agents can query.

**Configuration**: Upload documents → Create DataStore → Link to agent

**Example**:

* Agent queries company policies → RAG returns relevant documents

***

## 🔄 Workflow Types

### Sequential Workflow

**Pattern**: A → B → C (one after another)

**Use Case**: Multi-step processes where each step depends on the previous.

**Example**: Brand Factbook Generation

```
User Request
  → DataCollector (gather data)
  → Analyzer (process data)
  → ReportGenerator (create PDF)
```

### Parallel Workflow

**Pattern**: A + B + C (simultaneously)

**Use Case**: Independent tasks that can run concurrently.

**Example**: Multi-Source Data Collection

```
User Request
  ├── DataCollector (get DataCollector data)
  ├── CRCollector (get CR data)
  └── SalesforceCollector (get CRM data)
  → Aggregator (combine results)
```

### Loop Workflow

**Pattern**: Repeat until condition met

**Use Case**: Iterative refinement or retry logic.

**Example**: Content Improvement

```
User Request
  → DraftWriter (create v1)
  → Reviewer (check quality)
  → IF quality < threshold: DraftWriter (improve) → Reviewer
  → ELSE: Return final draft
```

### Hybrid Workflow

**Pattern**: Combination of above

**Example**: Complex Business Process

```
Orchestrator
  → VerificationAgent (check inputs)
  → DataWorkflow (Sequential)
      ├── Collector1 (Parallel)
      ├── Collector2 (Parallel)
      └── Collector3 (Parallel)
      → Aggregator (combine)
  → AnalysisAgent (process)
  → ReportAgent (generate output)
```

***

## ✨ Core Capabilities

### A. Agent Routing

**What**: Direct requests to specific agents based on keywords.

**How**: Mention agent names in Orchestrator's system prompt.

**Example**:

```markdown theme={null}
이메일 요청 → EmailAgent 전송
데이터 분석 요청 → DataAgent 전송
```

### B. Tool & MCP Calls

**What**: Agents call external functions and APIs.

**How**: List tools/MCP in agent config, mention in prompt.

**Example**:

```markdown theme={null}
사용 가능한 도구:
- send_email: 이메일 발송
- search_crm: CRM 검색
```

### C. RAG Queries

**What**: Agents retrieve information from uploaded documents.

**How**: Upload docs → Link DataStore → Mention knowledge domains in prompt.

**Example**:

```markdown theme={null}
회사 정책 문서에서 휴가 규정 검색
```

### D. Data Passing

**What**: Pass structured data between agents in workflows.

**How**: Set `output_key` in parent, `include_contents` in child.

**Example**:

```
DataCollector (outputs: collected_data)
  → Analyzer (receives: collected_data)
```

### E. Flexible Patterns

**What**: Conditional logic and dynamic behavior.

**How**: Write if/else logic in system prompts.

**Example**:

```markdown theme={null}
IF 긴급 요청:
  → UrgentAgent
ELSE:
  → NormalAgent
```

***

## 🛠️ Configuration Methods

### 1. Admin UI (Recommended)

**Easiest way** to configure agents - no code required.

**Steps**:

1. **Agent Management** → Create agents
2. **Edit Agent** → Set system prompt, tools, MCP, RAG
3. **Relationships** → Link agents together
4. **Test** → Send requests and monitor

### 2. API (Programmatic)

Use Junis API for automation or bulk operations.

**Endpoints**:

* `POST /api/admin/agents` - Create agent
* `PUT /api/admin/agents/{id}` - Update agent
* `POST /api/admin/agents/{id}/relationships` - Link agents

**Documentation**: See [API Reference](/api-reference/authentication)

***

## 📊 Monitoring & Optimization

### Usage Tracking

**View in Admin UI**:

* **Usage** → Agent usage statistics
* Session logs and conversation history
* Agent routing flow visualization

### Performance Optimization

**Best Practices**:

1. **Cache frequently-used agents** (automatic in Junis)
2. **Use Parallel workflows** for independent tasks
3. **Optimize prompts** for clarity and conciseness
4. **Monitor token usage** and adjust as needed

***

## 🚀 Quick Start

### 1. Simple Routing Example

**Goal**: Create Orchestrator that routes to 2 agents.

**Steps**:

1. Create 3 agents:
   * `Orchestrator` (LLM\_AGENT)
   * `EmailAgent` (LLM\_AGENT)
   * `DataAgent` (LLM\_AGENT)
2. Set Orchestrator prompt:
   ```markdown theme={null}
   이메일 요청 → EmailAgent 전송
   데이터 요청 → DataAgent 전송
   ```
3. Link agents: Orchestrator → EmailAgent, DataAgent
4. Test: "Send email" → Routes to EmailAgent

### 2. Multi-Step Workflow

**Goal**: Create Sequential workflow (A → B).

**Steps**:

1. Create 3 agents:
   * `Orchestrator` (LLM\_AGENT)
   * `DataWorkflow` (SEQUENTIAL\_AGENT)
   * `CollectorAgent` (LLM\_AGENT)
   * `AnalyzerAgent` (LLM\_AGENT)
2. Link: DataWorkflow → CollectorAgent (order 1), AnalyzerAgent (order 2)
3. Link: Orchestrator → DataWorkflow
4. Test: "Analyze data" → CollectorAgent → AnalyzerAgent

### 3. Tool Integration

**Goal**: Agent that calls a tool.

**Steps**:

1. Create `SearchAgent` (LLM\_AGENT)
2. Add tool in config: `["search_database"]`
3. Set prompt:
   ```markdown theme={null}
   도구: search_database
   사용자 검색 요청 시 search_database 호출
   ```
4. Test: "Search for X" → Calls tool

***

## 📖 Next Steps

<CardGroup cols={2}>
  <Card title="Prompt Engineering Guide" icon="wand-magic-sparkles" href="/guides/orchestration/prompt-engineering">
    **Start Here**: Learn to configure agents with prompts
  </Card>

  <Card title="Agent System Deep Dive" icon="sitemap" href="/getting-started/agent-system">
    Understand agent types and architecture
  </Card>

  <Card title="Tools Development" icon="wrench" href="/guides/tools/overview">
    Create custom tools for agents
  </Card>

  <Card title="MCP Integration" icon="plug" href="/guides/mcp/overview">
    Connect external platforms (GitHub, Firecrawl, etc.)
  </Card>

  <Card title="Squad Collaboration" icon="people-arrows" href="/guides/orchestration/squad-collaboration">
    Let one squad's orchestrator ask another squad and relay the answer
  </Card>
</CardGroup>

***

## ❓ FAQ

<AccordionGroup>
  <Accordion title="Do I need to write code?" icon="code">
    **No!** Junis orchestration is entirely prompt-based. Configure agents through the Admin UI with system prompts. Code is only needed for custom tools or advanced integrations.
  </Accordion>

  <Accordion title="How many agents can I create?" icon="infinity">
    No hard limit. However, we recommend:

    * **Orchestrator**: 1 per organization
    * **Sub-agents**: 5-20 for most use cases
    * **Nested workflows**: Max 3-4 levels deep
  </Accordion>

  <Accordion title="Can agents share data?" icon="share-nodes">
    **Yes!** Use **output keys** and **include contents** to pass data between agents in Sequential workflows. See [Prompt Engineering Guide](/guides/orchestration/prompt-engineering#d-output-format--key-passing).
  </Accordion>

  <Accordion title="What if an agent fails?" icon="triangle-exclamation">
    * **Automatic retry**: Junis retries failed tool/MCP calls once
    * **Error handling**: Agents receive error messages and can handle gracefully
    * **Monitoring**: View errors in Usage logs
    * **Recovery**: Update agent prompts to handle edge cases
  </Accordion>

  <Accordion title="How do I test changes?" icon="flask">
    1. **Edit agent** → Save (cache auto-refreshes)
    2. **Send test message** in Chat UI
    3. **Check Usage logs** for routing and tool calls
    4. **Iterate** on prompts based on results
  </Accordion>
</AccordionGroup>

***

## 🎓 Learning Path

**Beginner**:

1. Read this overview
2. Follow [Quick Start](#quick-start) examples
3. Try [Prompt Engineering Guide](/guides/orchestration/prompt-engineering)

**Intermediate**:

1. Build Sequential and Parallel workflows
2. Integrate tools and MCP
3. Use RAG for knowledge retrieval

**Advanced**:

1. Create complex hybrid workflows
2. Optimize performance with caching
3. Build custom tools and MCP integrations

***

**Ready to build?** Start with the [Prompt Engineering Guide](/guides/orchestration/prompt-engineering) → 🚀
