Skip to content

Architecture

๐ŸŽฏ Design Principles

Kourai Khryseai is built around transparency and interactivity:

  • Specialization: Each agent handles one discipline โ€” planning, coding, testing, style, commits, companionship, romance, quality screening, or research validation. Specialists are focused and use appropriate model tiers.
  • Real-time feedback: Agents stream their work as it happens. You don't wait for "final output"โ€”you see reasoning in progress.
  • Human-on-the-loop: When decisions matter (architecture choices, scope boundaries, validation rules), agents ask. You're never out of control.
  • Composable: Agents are independent HTTP services. They can be deployed separately, tested independently, or replaced with custom implementations.
  • Observable: Every request creates a distributed trace. See exactly what each agent did and how long it took.

๐Ÿ—บ๏ธ System Diagram

flowchart TD
    CLI["๐Ÿ–ฅ๏ธ <b>CLI REPL</b><br/><code>make cli</code>"]
    GUI["๐ŸŽฎ <b>Pygame GUI</b><br/><code>make gui</code>"]
    VN["๐Ÿ“– <b>Ren'Py VN</b><br/>Visual Novel"]
    HEP["๐Ÿ”ฅ <b>HEPHAESTUS</b><br/>Orchestrator ยท :10000<br/><i>LLM routing ยท pipeline ยท context</i>"]

    subgraph core ["Core Specialists"]
        MET["๐Ÿ“ <b>METIS</b><br/>Planner ยท :10001"]
        TEC["โš™๏ธ <b>TECHNE</b><br/>Coder ยท :10002"]
        DOK["๐Ÿงช <b>DOKIMASIA</b><br/>Tester ยท :10003"]
        KAL["โœจ <b>KALLOS</b><br/>Stylist ยท :10004"]
        MNE["๐Ÿ“œ <b>MNEME</b><br/>Scribe ยท :10005"]
    end

    subgraph spirits ["Companion Spirits"]
        PUC["๐ŸŽญ <b>PUCK</b><br/>Guide ยท :10006"]
        CUP["๐Ÿ’˜ <b>CUPID</b><br/>Romance ยท :10007"]
    end

    subgraph validators ["Quality Validators"]
        AID["๐Ÿชž <b>AIDOS</b><br/>Anti-Slop ยท :10008"]
        ALE["๐Ÿ“š <b>ALETHEIA</b><br/>Research ยท :10009"]
    end

    JAE["๐Ÿ” <b>JAEGER</b><br/>:16686 UI ยท :4318 OTLP"]
    PRO["๐Ÿ“Š <b>PROMETHEUS</b><br/>:9090 UI ยท Metrics"]

    CLI -->|"A2A message/stream (SSE)"| HEP
    GUI -->|"A2A message/stream (SSE)"| HEP
    VNB["๐ŸŒ‰ <b>VN-BRIDGE</b><br/>HTTP ยท :10010<br/><i>NDJSON streaming</i>"]
    VN -->|"HTTP (urllib)"| VNB
    VNB -->|"A2A message/stream"| HEP
    HEP -->|"A2A blocking"| MET
    HEP -->|"A2A blocking"| TEC
    HEP -->|"A2A blocking"| DOK
    HEP -->|"A2A blocking"| KAL
    HEP -->|"A2A blocking"| MNE
    HEP -->|"A2A on-demand"| PUC
    HEP -->|"A2A on-demand"| CUP
    HEP -->|"A2A on-demand"| AID
    HEP -->|"A2A on-demand"| ALE
    HEP -.->|"OTLP traces"| JAE
    JAE <-->|"RED metrics (SPM)"| PRO

๐Ÿ”— Communication Patterns

User โ†” Hephaestus: Streaming (SSE)

All three hosts (CLI, Pygame GUI, Ren'Py VN) connect to Hephaestus using A2A message/stream with Server-Sent Events. This means you see real-time progress as each agent reports status โ€” not a single response after everything finishes. The VN connects through a dedicated vn-bridge Docker service (:10010) that translates between HTTP/NDJSON and the A2A protocol. Ren'Py sends requests via urllib to the bridge, which streams A2A events from Hephaestus and returns them as newline-delimited JSON.

# CLI sends a streaming request
request = SendStreamingMessageRequest(
    id=str(uuid4()),
    params=MessageSendParams(
        message=Message(
            role=Role.user,
            parts=[Part(root=TextPart(text=user_text))],
            context_id=context_id,
        ),
        configuration=MessageSendConfiguration(
            accepted_output_modes=["text"],
        ),
    ),
)

async for result in client.send_message_streaming(request):
    # TaskStatusUpdateEvent โ†’ progress messages
    # TaskArtifactUpdateEvent โ†’ final output
    ...

Hephaestus โ†” Specialists: Asynchronous Streaming (HOTL)

Kourai Khryseai utilizes a Human-on-the-Loop (HOTL) architecture. Hephaestus calls specialists using an asynchronous AsyncGenerator wrapper over the A2A client with streaming=True.

This enables specialists to actively stream their "inner monologues" (e.g., โš™๏ธ Coding: def parse_ast(node)...) to Hephaestus, which immediately pipes them back to the GUI. The execution of the pipeline remains sequential (Hephaestus waits for Techne's final artifact before calling Dokimasia), but the generation phase is entirely transparent.

# RemoteAgentConnection.send() โ€” simplified
async for event in client.send_message(message):
    if isinstance(event, Message):
        yield ("result", extract_text(event))
    else:
        task, update = event
        if isinstance(update, TaskStatusUpdateEvent):
            yield ("status", extract_status(update))

Direct Specialist Handoffs

To facilitate true conversational interaction, the GUI supports @agent mentions. A request starting with @techne will bypass Hephaestus's normal pipeline routing logic entirely, instantly initiating a 1-on-1 pipeline with that agent.

Input Required: Clarification Loop

When a specialist needs user input, it raises AgentInputRequired. Hephaestus catches this and yields an INPUT_REQUIRED: status. The CLI detects this state and prompts the user for follow-up, then resends to continue the pipeline.