Skip to content

Latest commit

 

History

History
150 lines (121 loc) · 6.4 KB

ARCHITECTURE.md

File metadata and controls

150 lines (121 loc) · 6.4 KB

Conclave — Architecture

Monorepo

packages/
  core/   @conclave/core   all logic, zero harness deps (pipeline, providers, config, prompts, tools)
  cli/    conclave-cli      `conclave` terminal binary — thin wrapper over core
  mcp/    conclave-mcp      MCP stdio server exposing the `conclave` tool — thin wrapper over core

core holds every decision and all the tests. The CLI and MCP server are ~100-line adapters that call runFusion(). Both surfaces share one tested core.

The pipeline

your prompt
     │
     ▼
STAGE 0 · PREPARER (optional, 1 model)
     clarifies/frames the task; with tools it researches and grounds shared facts.
     Phase 1: tool-free passthrough.  Phase 2+: web search/fetch.
     Never assigns the panel a lens; never pre-answers the task.
     │  enriched prompt → everyone
     ▼
STAGE 1 · PANEL (N models, EACH individually configured)
     all answer the SAME prompt IN PARALLEL (concurrency-capped, default 4).
     each panelist: own provider/model/temperature/maxTokens/persona/tools.
     answers are ANONYMIZED → "Answer A/B/C"; the label→model map never reaches the judge.
     empty output = failure (kept out of the judge).
     │
     ▼
GATE   0 succeed → classified error (insufficient_credits | rate_limited | all_panels_failed)
       1 succeed → return it directly (no judge — needs ≥2 to compare)
       ≥2        → judge
     │
     ▼
STAGE 2 · JUDGE / ORCHESTRATOR (1 model + smart prompt)
     sees the BLIND answers; compares (no merge, no majority vote);
     emits five-field JSON {consensus, contradictions(+adjudication), partial_coverage,
     unique_insights, blind_spots}; then writes the single best final answer.
     │
     ▼
final answer (Markdown)  +  run dir with all artifacts

Why blind judging

The most-cited critique of judge-based ensembling is that a judge measures "how close is this to what I'd have said" — reputation / self-preference bias. Anonymizing the answers (and never showing the judge which model wrote which) forces a decision on merit. The prompts also instruct the judge to ignore order, length, and self-similarity, and to treat the answers as untrusted data.

Writer mode

  • CLI: writer: "judge" (default) — the judge writes the final answer.
  • MCP: writer: "caller" (default) — Conclave returns the analysis + anonymized answers and the calling agent writes the final response (it's going to respond anyway; avoids a redundant call). Override either with config or the MCP writer param.

Providers & auth

Two wire shapes cover everything:

  • openai → POST {baseURL}/chat/completions (OpenAI, OpenRouter, Google/Gemini, Groq, Together, Ollama, vLLM, LM Studio, any compatible server)
  • anthropic → POST {baseURL}/messages

A provider is { name, transport, baseURL, apiKeyEnv? }. Built-ins: openai, anthropic, google, openrouter, groq, together, ollama. Auth resolution: explicit config → env var → ~/.conclave/auth.json. Keys are never logged or written to artifacts, and never sent to the judge.

Tools (phased rollout — all implemented)

The preparer and any panelist can be given a tool mode. Tools run in a bounded agentic loop (maxToolCalls, default 8) with circuit breakers (identical call 3×, or 3 consecutive errors, forces a final tool-free answer). All built-in tools are read-only.

  • Phase 1 — none: training-knowledge answers (default).
  • Phase 2 — web: web_search (Tavily/Brave via key, DuckDuckGo HTML fallback keyless) + web_fetch (HTML→text).
  • Phase 3 — fs: read, ls, grep, find, sandboxed to the working directory (path escape blocked).

Tool-enabled stages get a research instruction block appended (when to search, how much, when to stop, and how to ground claims).

Config reference

{
  "providers": [ { "name": "ollama", "transport": "openai", "baseURL": "http://localhost:11434/v1" } ],

  "preparer": {                      // optional Stage 0
    "provider": "openai", "model": "gpt-5.5",
    "tools": "none",                 // "none" | "web" | "fs"
    "maxToolCalls": 8,
    "enabled": true
  },

  "panel": [                         // Stage 1 — array of per-panelist blocks …
    { "id": "P1", "provider": "anthropic", "model": "claude-opus-4-8", "temperature": 0.7, "tools": "none" },
    { "id": "P2", "provider": "openai",    "model": "gpt-5.5",         "temperature": 0.3 },
    { "id": "P3", "provider": "google",    "model": "gemini-pro-latest","temperature": 0.9 }
  ],
  // … OR the self-panel form (same model asked N ways):
  // "panel": { "self": "anthropic/claude-opus-4-8", "ways": 3, "vary": ["temperature","persona"] },

  "judge": { "provider": "anthropic", "model": "claude-opus-4-8", "temperature": 0.2 },

  "run": {
    "panelConcurrency": 4,
    "anonymize": true,               // blind judging
    "saveArtifacts": true,           // write a run dir
    "writer": "judge"                // "judge" | "caller"
  }
}
Field Default Notes
panel[].provider/model auto-diverse provider/model; only authed models run
panel[].temperature 0.4 per panelist
panel[].systemPrompt persona-free default a custom persona overrides it
panel[].tools none none | web | fs
judge first panel model compares + writes the answer
preparer off runs only when configured
run.panelConcurrency 4 parallel cap
run.anonymize true strip identity before the judge
run.writer judge judge writes vs caller writes (MCP)

Run directory

Each run writes to ~/.conclave/runs/<timestamp>-<slug>/:

prompt.md      original + enriched prompt
preparer.md    preparer output (when it ran)
answer-A.md    anonymized panel answers — NO model names
answer-B.md
judge.md       judge analysis (JSON) + final answer
final.md       final answer alone
run.json       full record INCLUDING the label→model map (the only place identity is linked)

--report is the only view that de-anonymizes (it reads run.json's map). The judge never sees it.

Prompts

The stage prompts are original and apply well-known multi-model-deliberation and LLM-as-judge techniques: independence-then-synthesis, no manufactured personas on the default panel, blind judging, compare-don't-merge, contradiction adjudication by evidence, and disciplined web research. See packages/core/src/prompts.ts.