Skip to content

Conductor

"An Agent is a single note. The Conductor is the melody. It weaves the disparate reflexes of the machine into a synchronized Litany, ensuring that memory, rhythm, and sequence are preserved across the silence of the Void."

The Conductor is the Workflow Extension of the LychD system. It is the implementation of ADR 28 (Workflow)—the executive function that governs stateful, multi-step reasoning.

While the Graph provides the topology (nodes and edges), the Conductor provides the Tempo. It manages the movement of data between synapses, orchestrates the Long Sleep during hardware swaps, and ensures that every step of a ritual is hydrated with the correct context.

🎼 The Litany (Workflow Definition)

A Workflow in LychD is called a Litany. It is not a static script, but a stateful graph definition registered via the Extension Context.

# A simple Litany: Research -> Draft -> Review
@conductor.litany(name="deep_research")
async def research_litany(ctx: LitanyContext, topic: str):
    # Step 1: The Scout (Parallel Spreading)
    sources = await ctx.step(
        agent="researcher",
        intent=f"Find sources for {topic}",
        tools=["browser_navigate"]
    )

    # Step 2: The Synthesis (Memory Weaving)
    draft = await ctx.step(
        agent="writer",
        intent="Synthesize these sources.",
        context={"sources": sources} # Injected Memory
    )

    # Step 3: The Judgment (HitL)
    approved = await ctx.consecrate(draft)

🧠 The Archivist (Memory Weaving)

The Conductor solves the "Amnesia Problem" of stateless agents. Before invoking a step, it performs Memory Weaving.

  1. The Scry: It scans the Phylactery Archive for vectors relevant to the current step's intent.
  2. The Injection: It retrieves relevant Karma (past successes) and injects them into the Agent's RunContext.
  3. The Result: The Agent wakes up already knowing the history of the project. It does not need to be reminded of the Magus's preferences; they are woven into its reality.

⏸️ The Fermata (Stasis & Resilience)

The Conductor is the guardian of the Stasis Protocol.

  • Persistence: Every transition between steps is an atomic transaction in the Database. If the system crashes at Step 2, the Conductor reanimates the Litany at Step 2, not Step 0.
  • Hardware Pacing: If Step 1 uses Vision and Step 2 uses Audio, the Conductor pauses the workflow while the Orchestrator performs the Coven Swap. It ensures the "Mind" waits for the "Body."

🕵️ The Censor (Data Hygiene)

When a Litany involves external Legion Nodes or Portals, the Conductor activates the Censor Middleware.

  • Scrubbing: It scans outgoing artifacts for sensitive patterns (API Keys, PII) defined in the Ward.
  • Anonymization: It replaces sensitive entities with tokens before they leave the Sepulcher.
  • Re-Identification: When the result returns, the Conductor reintegrates the real data, ensuring the external world never sees the true face of the Magus.

The Visual Score

The Conductor automatically generates Mermaid Diagrams for every active Litany. The Magus can watch the flow of thought in real-time at the Altar, seeing exactly which node is active and which memories were woven into it.