Skip to main content

Overview

Shannon’s template system enables deterministic, zero-token workflows for common patterns. Templates define structured workflows in YAML that execute without AI decomposition, providing significant cost savings for repeatable tasks.

Zero Token Cost

Templates bypass LLM calls for workflow routing

Deterministic Execution

Predictable, repeatable workflow behavior

Budget Control

Per-node token limits with automatic degradation

DAG Support

Parallel execution with dependency management

When to Use Templates

Use templates when:
  • Workflows are repeatable with known structure
  • You want to eliminate decomposition token costs
  • Predictable execution order is required
  • Budget control per workflow stage is needed
Use AI decomposition when:
  • Task structure is unknown or variable
  • Complex reasoning about workflow design is needed
  • One-off or highly dynamic tasks

Template Structure

Templates are YAML files with this structure:

Core Fields

Default Settings

Node Types

Shannon supports four node types for different execution patterns:

Simple Nodes

Single-task execution with direct tool invocation.
Use for: Data fetching, simple transformations, tool-based operations.

Cognitive Nodes

Complex reasoning with multi-step analysis.
Use for: Analysis, reasoning, synthesis tasks.

DAG Nodes

Parallel execution with internal task dependencies.
Use for: Parallel processing, fan-out/fan-in patterns.

Supervisor Nodes

Hierarchical task decomposition and coordination.
Use for: Result aggregation, quality control, synthesis.

Execution Strategies

Strategies define how nodes process tasks:

Automatic Degradation

When budget constraints are reached, strategies degrade automatically:
Configure explicit degradation:

Creating Templates

1

Create Template File

Create a YAML file in config/workflows/examples/ or your custom directory:
2

Register Template Directory

Templates are loaded at startup via InitTemplateRegistry:
3

Restart Services

4

List Available Templates

Via gRPC:

Using Templates

Via HTTP Gateway

Via gRPC

Set disable_ai: true to enforce template-only execution without AI fallback.

Via Python SDK

Template Examples

Simple Analysis Workflow

Two-stage pipeline for quick summarization:

Research Summary Workflow

Four-stage research pipeline with progressive reasoning:

Parallel DAG Workflow

Complex workflow with parallel execution branches:

Template Inheritance

Templates can inherit from parent templates using extends:
Multiple parents are applied in order, with the derived template’s values taking precedence.

Validation

Templates are validated at load time for:
  • YAML syntax correctness
  • Required field presence
  • DAG acyclicity (no circular dependencies)
  • Budget hierarchy (node budgets ≤ agent budget)
  • Tool registry existence
  • Variable reference resolution

Best Practices

Each node should do one thing well:
Restrict tools per node for security and predictability:
Configure fallback strategies for cost control:
Extract shared defaults into base templates:
Use semantic versioning and specify version in requests:

Troubleshooting

Symptom: template 'my_workflow' not foundSolutions:
  1. Check template file exists in registered directory
  2. Verify YAML syntax: yamllint config/workflows/examples/my_workflow.yaml
  3. Restart orchestrator to reload templates
  4. Check orchestrator logs for load errors
Symptom: Template validation failed: circular dependencySolutions:
  1. Review depends_on fields for cycles
  2. Ensure DAG nodes have acyclic task dependencies
  3. Check edges don’t create loops
Symptom: Node execution stops early or degrades unexpectedlySolutions:
  1. Increase budget_max for affected nodes
  2. Configure degrade_to for graceful fallback
  3. Review total budget vs. sum of node budgets
Symptom: tool 'my_tool' not registeredSolutions:
  1. Verify tool is registered in tool registry
  2. Check tool name spelling in tools_allowlist
  3. Ensure LLM service has tool loaded

Synthesis Templates

Synthesis templates control how Shannon formats final output after all agents complete their work. These Go templates live in config/templates/synthesis/ and are rendered by the Orchestrator before returning results.

Available Templates

Base Contract

All synthesis templates inherit behavioral rules from _base.tmpl:
  • When CitationAgent is enabled: no inline [n] citations in synthesis — Citation Agent adds them separately
  • When CitationAgent is disabled: use inline [n] matching the AvailableCitations list
The CurrentDate field is injected into every template, enabling “as of” statements for time-sensitive content.
Templates must preserve structured artifacts (tables, code blocks, JSON) — never flatten them to prose.
Templates should not include a “Sources” section. The system appends source citations automatically.

Template Data

Every synthesis template receives a SynthesisTemplateData struct with the following fields:

Selecting a Synthesis Template

The Orchestrator selects synthesis templates based on the task type and configuration:
If no synthesis_style is specified, Shannon automatically selects research_comprehensive for research tasks and normal_default for all others.

Example Workflows

Shannon ships with 8 example workflow templates in config/workflows/examples/. These serve as ready-to-use starting points and reference implementations.

Workflow Catalog

YAML Structure Reference

All example workflows follow this structure:

Pattern Degradation

Example workflows demonstrate Shannon’s automatic degradation behavior when resources are constrained:
Degradation is automatic and logged. Check Orchestrator logs for strategy_degraded events to monitor when fallbacks activate.

Learning Router

When enabled, the Learning Router automatically selects workflow templates based on query similarity to past successful executions. This eliminates the need for callers to specify a template explicitly.
The Learning Router improves over time. For new deployments, explicitly specify templates until enough execution history accumulates (typically 50+ successful tasks).

Next Steps

Custom Tools

Add tools for your templates

Extending Shannon

Other extension methods

Configuration

Environment and YAML config

Architecture

Understanding Shannon’s design