Skip to main content

Agent System Overview

Junis provides four types of agents that work together to handle any workflow, from simple Q&A to complex multi-step processes. This guide explains each agent type, when to use them, and how to combine them effectively.

The Four Agent Types

LLM Agent

Uses language models to generate responses, make decisions, and execute tasks

Sequential Agent

Executes agents in order, passing results from one to the next

Parallel Agent

Runs multiple agents simultaneously, combining their results

Loop Agent

Repeats agent execution until a condition is met or max iterations reached

LLM Agent

What It Does

LLM Agents are the workhorses of your AI system. They use language models (like Claude, gpt, or Gemini) to:
  • Generate natural language responses
  • Analyze and summarize text
  • Make decisions based on input
  • Call tools and APIs
  • Query knowledge bases (RAG)

When to Use

✅ Answering user questions ✅ Content generation (blogs, emails, summaries) ✅ Data analysis and insights ✅ Decision-making tasks ✅ Any task requiring language understanding

Configuration Options

LLM Agent Settings
name: My Agent
agent_type: LLM_AGENT
model: claude-haiku  # Or gpt, gemini, etc.

# Model Parameters
temperature: 0.7          # Creativity (0 = deterministic, 1 = creative)
max_output_tokens: 4096   # Response length limit
max_llm_calls: 3          # Max tool call iterations

# Instructions (System Prompt)
instruction: |
  You are a helpful assistant that answers questions about our product.
  Be concise, friendly, and accurate.

# Tools & Integrations
tools:
  - search_database
  - send_email
rag_tools:
  - rag_product_docs
mcp_platforms:
  - github
  - firecrawl

# Advanced
streaming_enabled: true      # Real-time response streaming
web_search_enabled: false    # Enable web search capabilities
output_key: null             # Extract specific field from response

# Extended Thinking (Claude models only)
enable_thinking: false       # Enable extended thinking mode
thinking_budget_tokens: 2048 # Token budget for thinking (min: 1024)
reasoning_effort: none       # "none", "low", "medium", "high"

Example: Customer Support Agent

  • Configuration
  • Example Conversation
name: Support Agent
agent_type: LLM_AGENT
model: claude-haiku
temperature: 0.5
instruction: |
  You are a customer support agent for Acme Corp.

  Responsibilities:
  1. Answer product questions using the knowledge base
  2. Troubleshoot common issues
  3. Escalate complex problems to human agents

  Always be empathetic and solution-oriented.

rag_tools:
  - rag_product_documentation
  - rag_faq_database

Sequential Agent

What It Does

Sequential Agents execute a series of agents in order, where each agent’s output becomes the next agent’s input. Think of it as a pipeline or assembly line.

When to Use

✅ Multi-step workflows (research → analyze → report) ✅ Data transformation pipelines ✅ Quality assurance (generate → review → refine) ✅ Complex decision trees ✅ When output of one task informs the next

Configuration Options

Sequential Agent Settings
name: My Sequential Workflow
agent_type: SEQUENTIAL_AGENT

# Sub-Agents (executed in order)
sub_agents:
  - agent_id: researcher
    order_index: 1
    description: Gathers information from multiple sources

  - agent_id: analyzer
    order_index: 2
    description: Analyzes and synthesizes research findings

  - agent_id: writer
    order_index: 3
    description: Writes final report based on analysis

# Optional: Define output format
output_key: final_report

Example: Content Creation Pipeline

  • Workflow Structure
  • Execution Flow
name: Blog Post Generator
agent_type: SEQUENTIAL_AGENT

sub_agents:
  # Step 1: Research
  - agent: Topic Researcher
    order: 1
    role: Search web and knowledge base for relevant information

  # Step 2: Outline
  - agent: Content Outliner
    order: 2
    role: Create structured outline from research

  # Step 3: Writing
  - agent: Blog Writer
    order: 3
    role: Write engaging blog post following outline

  # Step 4: SEO Optimization
  - agent: SEO Optimizer
    order: 4
    role: Add keywords, meta description, headings

Best Practices

  • Each sub-agent should have ONE clear responsibility
  • Don’t try to do too much in a single step
  • Break complex tasks into 3-5 discrete steps
Bad Example: “Research, analyze, and write report” (one agent) Good Example: Research Agent → Analysis Agent → Writing Agent (three agents)
When you need specific data from a step, use output_key to extract it:
- agent: Data Extractor
  order: 1
  output_key: extracted_data  # Only pass this field to next step
This prevents information overload in later steps.
Insert validation agents to ensure quality:
sub_agents:
  - agent: Content Generator
    order: 1
  - agent: Quality Checker    # ← Validates output
    order: 2
  - agent: Formatter
    order: 3

Parallel Agent

What It Does

Parallel Agents run multiple agents simultaneously and combine their results. Perfect for gathering information from multiple sources or performing independent tasks concurrently.

When to Use

✅ Data collection from multiple sources ✅ Independent analyses that can run concurrently ✅ Speeding up workflows with parallelization ✅ Comparing different approaches ✅ Aggregating diverse perspectives

Configuration Options

Parallel Agent Settings
name: My Parallel Workflow
agent_type: PARALLEL_AGENT

# Sub-Agents (executed simultaneously)
sub_agents:
  - agent_id: source_a_collector
    description: Fetches data from Source A

  - agent_id: source_b_collector
    description: Fetches data from Source B

  - agent_id: source_c_collector
    description: Fetches data from Source C

# Results are automatically combined
# Order doesn't matter for parallel execution

Example: Multi-Source Data Aggregator

  • Workflow Structure
  • Execution Timeline
  • Combined Output
name: Market Research Aggregator
agent_type: PARALLEL_AGENT

sub_agents:
  # All run simultaneously
  - agent: Competitor Analysis Agent
    role: Analyze competitor websites and pricing

  - agent: Social Media Insights Agent
    role: Gather sentiment from Twitter, Reddit, LinkedIn

  - agent: Industry News Agent
    role: Summarize latest industry news and trends

  - agent: Customer Feedback Agent
    role: Analyze recent customer reviews and support tickets

Best Practices

Parallel agents should NOT depend on each other’s results:Bad Example: Agent A calculates total, Agent B calculates percentage of total Good Example: Agent A analyzes Dataset 1, Agent B analyzes Dataset 2 (independent)
If one parallel agent fails, others should still complete:
# Enable fault tolerance
parallel_agent:
  continue_on_error: true  # Don't stop if one agent fails
  timeout: 30              # Max wait time per agent (seconds)
After parallel execution, add a Sequential step to combine results:The Compiler Agent synthesizes parallel results into a coherent response.

Loop Agent

What It Does

Loop Agents repeat execution until a condition is met or maximum iterations reached. Useful for iterative refinement, retry logic, and self-correcting workflows.

When to Use

✅ Iterative refinement (generate → evaluate → improve) ✅ Retry logic with exponential backoff ✅ Quality assurance loops ✅ Self-correcting systems ✅ Tasks requiring multiple attempts

Configuration Options

Loop Agent Settings
name: My Loop Workflow
agent_type: LOOP_AGENT
max_llm_calls: 5  # Maximum iterations (prevents infinite loops)

# Sub-Agent to Loop
sub_agents:
  - agent_id: iterative_improver
    description: Improves output each iteration

# Exit Conditions (implicit)
# - Condition evaluates to true
# - Max iterations reached
# - Agent returns success signal

Example: Code Review and Refinement

  • Workflow Structure
  • Iteration Example
  • Max Iterations Handling
name: Code Quality Loop
agent_type: LOOP_AGENT
max_llm_calls: 3

sub_agents:
  - agent: Code Generator
    role: Generate Python function based on requirements

  - agent: Code Reviewer
    role: |
      Review code for:
      - Correctness
      - Edge cases
      - Best practices
      - Security issues

      If issues found, provide specific feedback for next iteration.
      If code is acceptable, respond with "APPROVED".

Best Practices

The sub-agent should explicitly signal when to exit:
instruction: |
  Review the output. If quality is acceptable, respond with:
  "EXIT: Quality standards met"

  Otherwise, provide specific improvement suggestions.
  • 2-3 iterations: Quick refinement tasks
  • 3-5 iterations: Moderate complexity
  • 5-10 iterations: Complex optimization (rare)
Higher values increase cost and latency. Most tasks converge in 2-3 iterations.
Pass iteration count to the agent for context:
instruction: |
  This is iteration {{iteration_count}} of {{max_iterations}}.
  Previous feedback: {{previous_feedback}}

  Improve the output based on feedback.
Handle max iterations gracefully:
# After loop exits
if iterations >= max_llm_calls:
  escalate_to_human_review()
  log_warning("Loop did not converge")
  return best_attempt

Combining Agent Types

The real power of Junis comes from combining different agent types to build sophisticated workflows.

Example: Full Blog Post System

1

Orchestrator Routes Request

User says: “Write a blog post about quantum computing”Orchestrator recognizes this as a content creation task and routes to Content Pipeline (Sequential Agent).
2

Sequential Agent Coordinates Workflow

Content Pipeline executes three stages:
  1. Research (Parallel Agent)
  2. Writing (Loop Agent)
  3. Optimization (LLM Agent)
3

Parallel Agent Gathers Research

Research Team runs three agents simultaneously:
  • Web Researcher: Latest quantum computing news
  • Doc Researcher: Academic papers from knowledge base
  • Expert Interview Agent: Queries interview transcripts
Results feed into Compiler Agent that synthesizes a research brief.
4

Loop Agent Refines Content

Writer + Reviewer Loop:
  • Writer drafts blog post from research
  • Reviewer checks quality, accuracy, readability
  • Loop continues until approved (max 3 iterations)
5

Final Agent Optimizes for SEO

SEO Optimizer adds:
  • Meta description
  • Keywords
  • Heading structure
  • Internal links
Output: Publication-ready blog post delivered in ~45 seconds.

Agent Selection Guide

Not sure which agent type to use? Follow this decision tree:
  • Decision Matrix
  • Complexity Guide
ScenarioAgent TypeReason
Answer a questionLLM AgentSingle-step task
Research → Analyze → ReportSequentialMulti-step, order matters
Check 3 databases simultaneouslyParallelIndependent, concurrent
Generate → Review → ImproveLoopIterative refinement
Route to appropriate handlerOrchestratorDynamic dispatching

Common Patterns

Use Case: Generate insights from data
Sequential Agent:
  - Parallel Research: Gather data from multiple sources
  - LLM Analysis: Identify trends and patterns
  - LLM Report Writer: Create executive summary
Use Case: Quality assurance
Loop Agent:
  - LLM Generator: Create output
  - LLM Validator: Check against criteria
  - If invalid: Provide feedback and retry
  - If valid: Exit loop
Use Case: Smart routing
Sequential Agent:
  - LLM Triage: Classify request
  - Orchestrator: Route to specialist agent
  - Specialist LLM: Handle request
Use Case: Evaluate multiple approaches
Parallel Agent:
  - LLM Approach A: Conservative solution
  - LLM Approach B: Creative solution
  - LLM Approach C: Balanced solution

Then:
  - LLM Evaluator: Pick best approach

Performance Considerations

Latency

  • LLM Agent: 2-10 seconds
  • Sequential Agent: Sum of sub-agents
  • Parallel Agent: Max of sub-agents
  • Loop Agent: Iterations × agent time

Cost

  • LLM Agent: 1 LLM call
  • Sequential Agent: N LLM calls
  • Parallel Agent: N LLM calls (concurrent)
  • Loop Agent: Up to max_iterations × calls

Optimization Tips

1

Use Faster Models

  • Development: Claude Haiku (fast, cheap)
  • Production: Claude Sonnet (balanced)
  • Complex Tasks Only: Claude Opus / GPT-4
Switching from Opus to Haiku can reduce latency by 5-10x and costs by 60x.
2

Enable Streaming

streaming_enabled: true  # Show tokens as they arrive
Improves perceived performance even if total time is the same.
3

Limit Parallel Agents

  • 2-3 parallel agents: Optimal for most cases
  • 4-5 parallel agents: Acceptable with monitoring
  • 6+ parallel agents: Risk rate limiting and high costs
Consider Sequential + Parallel hybrid instead of large Parallel groups.
4

Set Conservative max_llm_calls

Loop Agent:
  max_llm_calls: 3  # Rarely need more than 3 iterations
Most loops converge in 2-3 iterations. Higher values rarely improve output quality.

Next Steps


Questions? Contact us at [email protected] to discuss agent architectures and get expert guidance.