Skip to main content

Prompt Engineering for Agent Orchestration

🎯 Overview

Junis uses prompt-based orchestration where you control agent behavior entirely through system prompts (instruction templates). No code changes needed - just configure your prompts in the Admin UI. This guide provides production-tested patterns that work directly in your Junis system.

🧠 Core Concepts

How Junis Routing Works

Key Point: Orchestrator decides routing based on keywords in its system prompt.

Where to Configure

  1. Admin UI β†’ Agent Management β†’ Select Agent
  2. Edit Agent β†’ Instruction Template field
  3. Paste your prompt β†’ Save
  4. Done! Agent automatically reloads

πŸ”€ A. Sub-Agent Routing

How It Works

Mention sub-agent names in your Orchestrator’s instruction template, and the LLM will route requests to them based on keywords.

βœ… Working Example (From Production)

This is the actual default Orchestrator prompt in Junis:

πŸ“‹ Pattern Breakdown

Structure:
Why It Works:
  • βœ… Explicit agent names (EmailWorkflow, etc.)
  • βœ… Clear keywords for pattern matching
  • βœ… Examples guide the LLM’s response style

πŸ› οΈ How to Set Up

Step 1: Create Sub-Agents

  1. Admin UI β†’ Agent Management β†’ Create Agent
  2. Create your sub-agents:
    • EmailWorkflow (LLM_AGENT)
    • DataWorkflow (SEQUENTIAL_AGENT)
  1. Select your Orchestrator agent
  2. Relationships tab β†’ Add Relationship
  3. Add each sub-agent with order index (1, 2, 3…)

Step 3: Configure Orchestrator Prompt

  1. Edit Orchestrator β†’ Instruction Template
  2. Paste routing logic (see example above)
  3. Save β†’ Cache automatically refreshes

✨ Advanced Routing Patterns

Multi-Language Routing

Priority-Based Routing


πŸ› οΈ B. Tool Calls & MCP Integration

How It Works

Mention tool/MCP names in your agent’s instruction, and the LLM will call them when needed.

βœ… Working Example (Tool Call)

πŸ“‹ Pattern Breakdown

Structure:

πŸ”§ How to Configure Tools

Step 1: Register Tool in Admin UI

  1. Admin UI β†’ Tools Management
  2. Check available tools (system admin only)
  3. Note the exact function name

Step 2: Add to Agent Config

  1. Agent Management β†’ Select agent β†’ Edit
  2. Tools field β†’ Add tool names:
  3. Save

Step 3: Update Instruction Template

Include tool names and usage patterns in the instruction (see example above).

✨ MCP Integration Example

πŸ”§ How to Configure MCP

Step 1: Enable MCP Platform

  1. Admin UI β†’ MCP Platforms
  2. Check available platforms (GitHub, Firecrawl, etc.)
  3. Configure credentials (API keys, OAuth tokens)
  1. Agent Management β†’ Select agent β†’ MCP tab
  2. Add MCP Platform β†’ Select platform
  3. Priority Order: Lower number = higher priority

Step 3: Update Instruction Template

Mention MCP platform capabilities in your prompt (see example above).

πŸ“š C. RAG Datastore Queries

How It Works

Mention data types or topics in your instruction, and the LLM will query your RAG Datastore when needed.

βœ… Working Example

πŸ“‹ Pattern Breakdown

Structure:

πŸ—‚οΈ How to Set Up RAG

Step 1: Create DataStore

  1. Admin UI β†’ Knowledge Base β†’ Create DataStore
  2. Name: company-policies (use lowercase with hyphens)
  3. Upload documents: PDFs, DOCX, TXT files

Step 2: Add RAG Tool to Agent

  1. Agent Management β†’ Select agent β†’ Edit
  2. RAG Tools field β†’ Add:
    Format: rag_ prefix + DataStore name
  3. Save

Step 3: Update Instruction Template

Mention knowledge domains in your prompt (see example above).

⚠️ Important Notes

  • Model Requirement: RAG only works with Gemini models (e.g., gemini/gemini-1.5-flash)
  • DataStore Location: Must be in global location (not regional)
  • Naming: Use lowercase, hyphens only (e.g., rag_brand-knowledge)

πŸ”„ D. Output Format & Key Passing

How It Works

Define output format in parent agent, then reference output key in child agent to receive structured data.

βœ… Working Example (Parent Agent)

DB Configuration:
  • Output Key: collected_brand_data

βœ… Working Example (Child Agent)

DB Configuration:
  • Include Contents: collected_brand_data

πŸ“‹ Pattern Breakdown

Parent Agent:
Child Agent:

πŸ”§ How to Configure

Step 1: Parent Agent Setup

  1. Agent Management β†’ Select parent agent β†’ Edit
  2. Instruction Template: Define output format
  3. Output Key field: collected_brand_data
  4. Output Schema (optional): Define JSON schema
  5. Save

Step 2: Child Agent Setup

  1. Agent Management β†’ Select child agent β†’ Edit
  2. Instruction Template: Mention input data source
  3. Include Contents field: collected_brand_data
  4. Save
  1. Create Sequential Agent (e.g., DataWorkflow)
  2. Add relationships:
    • Order 1: DataCollector (parent)
    • Order 2: ReportCompiler (child)

✨ Advanced: Schema Validation

Define output schema for strict validation:
Add this to Output Schema field in Admin UI.

🎭 E. Flexible Application Patterns

Conditional Logic

Multi-Step Workflows

Dynamic Tool Selection

Error Handling


βœ… Best Practices

1. Be Explicit

❌ Bad: β€œHandle email requests” βœ… Good: β€œμ΄λ©”μΌ μž‘μ„±, λ‹΅μž₯, 전달 μš”μ²­ β†’ EmailWorkflow μ—μ΄μ „νŠΈλ‘œ 전솑”

2. Provide Examples

Include example user inputs and agent responses in your prompts.

3. Use Clear Formatting

Structure your prompts with:
  • Numbered lists
  • Clear headers
  • Example blocks

4. Test Incrementally

  1. Test Orchestrator routing first
  2. Add one sub-agent at a time
  3. Verify each tool/MCP call individually
  4. Test complete workflow last

5. Monitor & Iterate

  • Check Usage Logs in Admin UI
  • Review agent routing events
  • Refine prompts based on real usage

πŸ› Troubleshooting

Agent Not Routing

Problem: Orchestrator responds directly instead of routing. Solution:
  • βœ… Check sub-agent name matches exactly in prompt
  • βœ… Verify agent relationship exists in Admin UI
  • βœ… Ensure sub-agent is active (not disabled)

Tool Not Called

Problem: Agent doesn’t call the tool. Solution:
  • βœ… Verify tool is added to Tools field in agent config
  • βœ… Mention tool name and usage in instruction
  • βœ… Check tool is registered in system (Tools Management)

MCP Call Fails

Problem: MCP platform error or timeout. Solution:
  • βœ… Verify MCP credentials in MCP Platforms settings
  • βœ… Check MCP platform is linked to agent (MCP tab)
  • βœ… Test MCP connection manually in Admin UI

RAG Returns No Results

Problem: RAG query returns empty or irrelevant results. Solution:
  • βœ… Verify DataStore has indexed documents
  • βœ… Check agent uses Gemini model (RAG only works with Gemini)
  • βœ… Ensure RAG tool name format: rag_[datastore-name]
  • βœ… Improve query phrasing in prompt

Output Key Not Passed

Problem: Child agent doesn’t receive parent output. Solution:
  • βœ… Parent agent must set Output Key field
  • βœ… Child agent must set Include Contents field with same key
  • βœ… Agents must be in Sequential flow (not Parallel)

Agent System Overview

Learn agent types and architecture

Tools Development

Create custom tools

MCP Integration

Connect external platforms

🎯 Summary

You now know how to: βœ… A. Route to sub-agents by mentioning agent names in prompts βœ… B. Call tools & MCP by listing available functions βœ… C. Query RAG Datastores by mentioning knowledge domains βœ… D. Pass data with output keys between agents βœ… E. Apply flexible patterns with conditional logic Next Steps:
  1. Open Admin UI β†’ Agent Management
  2. Create a simple Orchestrator with 2 sub-agents
  3. Test routing with different user inputs
  4. Gradually add tools, MCP, and RAG
Remember: No code changes needed - just configure prompts and save! πŸš€