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
Where to Configure
- Admin UI β Agent Management β Select Agent
- Edit Agent β Instruction Template field
- Paste your prompt β Save
- 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:- β 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
- Admin UI β Agent Management β Create Agent
- Create your sub-agents:
EmailWorkflow(LLM_AGENT)DataWorkflow(SEQUENTIAL_AGENT)
Step 2: Link to Orchestrator
- Select your Orchestrator agent
- Relationships tab β Add Relationship
- Add each sub-agent with order index (1, 2, 3β¦)
Step 3: Configure Orchestrator Prompt
- Edit Orchestrator β Instruction Template
- Paste routing logic (see example above)
- 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
- Admin UI β Tools Management
- Check available tools (system admin only)
- Note the exact function name
Step 2: Add to Agent Config
- Agent Management β Select agent β Edit
- Tools field β Add tool names:
- 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
- Admin UI β MCP Platforms
- Check available platforms (GitHub, Firecrawl, etc.)
- Configure credentials (API keys, OAuth tokens)
Step 2: Link MCP to Agent
- Agent Management β Select agent β MCP Skills tab
- Add MCP Platform β Select platform
- 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
- Admin UI β Knowledge Base β Create DataStore
- Name:
company-policies(use lowercase with hyphens) - Upload documents: PDFs, DOCX, TXT files
Step 2: Add RAG Tool to Agent
- Agent Management β Select agent β Edit
- RAG Tools field β Add:
Format:
rag_prefix + DataStore name - 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
globallocation (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)
- Output Key:
collected_brand_data
β Working Example (Child Agent)
- Include Contents:
collected_brand_data
π Pattern Breakdown
Parent Agent:π§ How to Configure
Step 1: Parent Agent Setup
- Agent Management β Select parent agent β Edit
- Instruction Template: Define output format
- Output Key field:
collected_brand_data - Output Schema (optional): Define JSON schema
- Save
Step 2: Child Agent Setup
- Agent Management β Select child agent β Edit
- Instruction Template: Mention input data source
- Include Contents field:
collected_brand_data - Save
Step 3: Link Agents
- Create Sequential Agent (e.g.,
DataWorkflow) - Add relationships:
- Order 1:
DataCollector(parent) - Order 2:
ReportCompiler(child)
- Order 1:
β¨ Advanced: Schema Validation
Define output schema for strict validation:π 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
- Test Orchestrator routing first
- Add one sub-agent at a time
- Verify each tool/MCP call individually
- 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 Skills 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)
π Related Documentation
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:- Open Admin UI β Agent Management
- Create a simple Orchestrator with 2 sub-agents
- Test routing with different user inputs
- Gradually add tools, MCP, and RAG
