Sub-Agents & Agentic Structures in Latitude

Latitude’s agentic framework lets you build powerful, modular, and autonomous LLM workflows. This page covers how to design, implement, and orchestrate sub-agents, specialized agents that can be invoked by other agents, enabling complex, multi-step reasoning and tool use.

What Are Agents and Sub-Agents?

Agent: A PromptL prompt with type: agent that can plan, act, and iterate autonomously, calling tools or other agents as needed. Sub-Agent: Any agent that is exposed as a callable function/tool within another agent, allowing for modular, reusable, and composable workflows.

When to Use Agents vs. Step Chains

Use an Agent when…Use a Chain when…
The workflow is open-ended or branchingThe workflow is strictly sequential
The model must decide which tools/agents to callThe steps are always the same
You want dynamic planning or iterationYou want deterministic, fixed steps
If you find yourself writing lots of conditional logic in a chain, consider switching to an agentic approach.

Defining an Agent in PromptL

To turn any prompt into an agent, add the following to your configuration header:
---
type: agent
provider: openai
model: gpt-4o
tools:
  - latitude/search
maxSteps: 40
---
  • type: agent enables agentic mode.
  • tools: lists external tools the agent can call.
  • maxSteps: (optional) limits the number of agent cycles.

Exposing Sub-Agents

You can expose other PromptL agent files as callable sub-agents using the agents: configuration key:
---
type: agent
agents:
  - agents/summarizer
  - agents/sentiment_analyzer
  - agents/researcher
---
Each listed agent becomes available as a callable function/tool. Sub-agents can themselves call tools or other sub-agents, enabling deep composition.

Sub-Agent Design Patterns

1. Single-Responsibility Helpers

Keep sub-agents focused. Example: a summarizer agent that only summarizes text.
---
type: agent
schema:
  type: object
  properties:
    summary: { type: string }
  required: [summary]
---
<system>
You are a summarizer. Return a concise summary of the provided text.
</system>

<user>
{{ input_text }}
</user>
It is essential that you include parameters in subagents so that the main agent can send them information.

2. Specialist Pool

A generalist agent can delegate to a pool of specialists:
---
type: agent
agents:
  - agents/summarizer
  - agents/sentiment_analyzer
  - agents/fact_checker
---
The agent can decide which specialist to call based on the task.

3. Sequential Orchestration

For strict order, use <step> blocks and specify which agent to call:
<step agents={{ ["agents/parser"] }}>
Parse the raw email and extract fields.
</step>

<step agents={{ ["agents/team_lookup"] }}>
Enrich team data via LinkedIn search.
</step>

<step agents={{ ["agents/recommender"] }}>
Produce a recommendation.
</step>

Agent Loop & Execution

On each cycle, the agent can return:
  • Tool calls only: Latitude executes the tools, appends results, and continues.
  • Text + tool calls: Treated as internal thinking; tools are run.
  • Text only: The loop ends; this is the agent’s final answer.
The loop stops when a text-only response is returned or maxSteps is reached.

Best Practices

  • Single Responsibility: Each sub-agent should do one thing well.
  • Clear I/O: Use schema to define expected outputs for each agent.
  • Resource Awareness: Each sub-agent call counts toward the parent’s maxSteps.
  • Testing: Use the Playground to debug and trace agent/sub-agent interactions.

Example: Multi-Agent Researcher

Main Agent Configuration

---
type: agent
agents:
  - agents/web_search
  - agents/summarizer
  - agents/citation_checker
schema:
  type: object
  properties:
    report: { type: string }
---

Main Agent Prompt

<system>
You are a research assistant. Use your sub-agents to gather, summarize, and fact-check information before producing a final report.
</system>
<user>
Research the latest trends in renewable energy.
</user>

Sub-Agents

  • agents/web_search: Searches the web for relevant articles.
  • agents/summarizer: Summarizes article content.
  • agents/citation_checker: Verifies the credibility of sources.

Debugging & Tracing

  • Use the Latitude Playground to step through agent execution.
  • Inspect each sub-agent’s output and reasoning.
  • Adjust schemas and instructions for clarity and reliability.

Further Reading


Examples

To see how agents and subagents work in context you are welcome to check out the following example agents:
  1. Example 1: Deep Search Agent
  2. Example 2: Customer Support Email Generator

Summary

Sub-agents and agentic structures in Latitude unlock modular, reusable, and powerful LLM workflows. By designing clear, focused agents and orchestrating them with the agentic loop, you can tackle complex, multi-stage tasks with reliability and transparency.