MadoHub Docs

Agent Routing

Automatically pass outputs and context between AI agents with intelligent transformation.

Agent routing is MadoHub's core orchestration engine. When one agent completes a task, MadoHub automatically captures its output, transforms it into a targeted, actionable prompt, and seamlessly dispatches it to downstream agents—enabling autonomous multi-agent pipelines.

How it works

  1. Trigger — A connected source tile activates routing based on your configured condition (idle detection, completion signal, keyword match, or continuous streaming).
  2. Extract — MadoHub captures the agent's latest output. For CLI agents like Claude Code, it utilizes native structured session extraction to eliminate terminal artifacts.
  3. Transform — The captured output is reshaped into an actionable prompt for the downstream agent via AI rewriting, template wrapping, or direct passthrough.
  4. Deliver — MadoHub delivers the prompt to the target terminal using adaptive pacing and agent-specific execution handshakes.

High-Fidelity Session Capture

In traditional multi-terminal automation, scraping terminal screens is notoriously fragile, often capturing messy ANSI escape sequences, progress spinners, and fragmented line wraps.

MadoHub employs native structured session capture:

  • Pure Context Extraction: Directly interfaces with the agent's structured session record to extract genuine assistant reasoning, code diffs, and tool results—completely free of terminal display noise.
  • Context-Aware Workspace Alignment: Automatically aligns canvas tiles with their underlying project directories, ensuring relative paths and file contexts remain accurate across handoffs.
  • Zero-Invasive Monitoring: Operates without modifying the agent's core source code, preserving native CLI integrity and stability.

Trigger Types

TypeBehavior & Use Case
on-idleIdle Detection (Recommended): Triggers after the agent finishes its turn and maintains a short period of silence. Most reliable.
on-completeCompletion Signal: Triggers as soon as the agent explicitly signals task completion.
on-keywordPattern Match: Fires immediately when output matches a specified regex or keyword.
alwaysContinuous Stream: Continuously streams new terminal output to the target agent in real time.

Transform Types

TypeDescription & Applications
ai-routingAI-Powered Synthesis (Core): Uses an AI model to generate a context-aware prompt tailored to the downstream agent. Configure models in Settings.
prompt-wrapTemplate Wrapping: Wraps output in a custom template. Variables: {output}, {round}, {maxRounds}, {source}.
summaryIntelligent Summary: Generates an AI-synthesized summary of key diffs and conclusions.
full-outputFull Passthrough: Forwards the last 30 lines of terminal output.
rawCompact Passthrough: Forwards the last 10 lines of terminal output.

Adaptive Terminal Delivery

To guarantee rock-solid prompt delivery across diverse terminal environments, MadoHub incorporates an adaptive dispatch protocol:

  • Intelligent Flow Control: Dynamically paces keystroke injection to match terminal buffer capacity, eliminating dropped characters during rapid handoffs.
  • Protocol-Aware Handshakes: Automatically tailors execution protocols for Claude Code, Codex, Amp, OpenCode, and standard shells to ensure deterministic execution.

Loop Safeguards

Routing connections include built-in safeguards to prevent runaway execution and token exhaustion:

SettingDefaultRangeDescription
maxRounds51–20Maximum routing cycles before automatic deactivation.
cooldownMs3s1–30sMinimum mandatory cooldown between successive triggers.
stopKeyword—Any stringAutomatically terminates routing when a stop phrase (e.g. "LGTM", "RESOLVED") is detected.

Example Workflow

Terminal 1 (Claude Code: Refactoring)    Terminal 2 (Claude Code: Code Review)
┌──────────────────────┐    →    ┌──────────────────────┐
│ "Refactor auth module"│         │ Receives:            │
│                       │         │ "Review the refactor │
│ ✓ Done — 3 files     │         │  in src/auth/..."    │
└──────────────────────┘         └──────────────────────┘

Agent 1 completes the refactoring. MadoHub captures the pure code changes, generates a focused review prompt via ai-routing, and delivers it to Agent 2 to start an independent review and testing pass.

On this page