Skip to content

Discussion Rooms

root edited this page Dec 4, 2026 · 4 revisions

Discussion Rooms

🌐 English · 简体中文

This page covers Trizano's multi-agent Discussion Rooms: how they differ from standard Delegation, the underlying engine and Approval proxy architecture, the five built-in modes, three-tier configuration overrides and Starlark scripting primitives, CLI/MCP entry points, and the Web UI workflow for creating and editing custom modes.

What Is a Discussion Room?

A Discussion Room is a virtual Session (agent = "discussion") driven by a deterministic moderator engine inside the Node. Guided by a Starlark script, it coordinates multiple agents in the same Workspace through structured rounds of discussion and synthesizes a conclusion.

Compared with standard Delegation in Multi-Agent Orchestration, the core difference is control flow and visibility isolation:

  • Standard Delegation: A parent LLM decides whom to call, when to read results, and how to relay one agent's output to another. This is flexible, but depends on parent-model context and prompt stability and easily suffers from anchoring or premature convergence.
  • Discussion Room: A deterministic Starlark script governs the protocol. The engine natively enforces per-participant visibility (seen_entry_ids—supporting blind first-round answers, incremental cross-examination, or staged reveals), hard budgets (rounds, wall clock, cost), Approval proxying, and a live discussion graph, with all participants protected as read-only by default.

Architecture

Discussion Rooms are not registered in driver factories or ListAgents. Instead, the Node Session layer constructs a virtual connection implementing driver.Conn, driver.Steerer, and driver.WatchReceiver (server/node/session/discussion/conn.go), reusing the standard Session event stream, timeline, and watch infrastructure.

flowchart TB
    U["User / Parent Agent"] -->|"SendMessage / Steer / AnswerPrompt"| R["Discussion Room Session (agent=discussion)"]
    subgraph Engine["discussion.Conn (single-owner loop)"]
        L["Conn.loop()"] <-->|"scriptReq / reply"| ST["Starlark script goroutine (run / finale)"]
        L --> G["Graph layout (layout.go)"]
    end
    R --- L
    L -->|"Send + Watch (discussion.Backend)"| P1["Participant child p1 (read_only by default)"]
    L -->|"Send + Watch"| P2["Participant child p2 (read_only by default)"]
    P1 -.->|"watch callback / needs_input"| WM["watchManager"]
    P2 -.->|"watch callback / needs_input"| WM
    WM -->|"DeliverWatch"| L
    L -.->|"Proxied Prompt bubble-up"| R
Loading

Moderation Loop and Script Execution

  • Single-owner model: Conn.loop() owns all room state. Each run spawns a short-lived Starlark goroutine with its own starlark.Thread. Script primitives send scriptReq messages to loop(): state reads, stage, say, link, and mark return immediately; ask and ask_user block until the full batch finishes or the user answers.
  • Dispatch and budgets: ask uses discussion.Backend (calling session.Manager directly on the same Node) to run Send → Watch(armed_turn) for each targeted participant. Before dispatching a batch, the engine snapshots visible entries so parallel speakers in the same batch cannot see one another's responses. After each batch, the engine checks round, wall-clock, and cost budgets. When run(room) returns normally, a budget is exhausted, or /summarize is received, the engine cancels the run context (thread.Cancel), stops active speakers, and executes finale(room) in a fresh thread with a 5m synthesis grace period (defaultSynthesisGrace) exempt from normal budget cutoffs.
  • Steering and @ mentions: Sending a mid-turn steer (SEND_MODE_STEER) appends to room.steers for delivery on the next ask; if the room is already in finale, handling a single-participant direct message, or at the round limit, it returns driver.ErrSteerQueue to fall back to queuing. Mentioning (@) a single participant triggers direct-reply mode (skipping the script); mentioning two or more narrows room.participants to those mentioned plus the chair.
  • Discussion graph (DiscussionGraph): The engine builds an execution tree (topic → stage → group → entry / ask_user) and recomputes coordinates live via server/node/session/discussion/layout.go (fixed 200×56 nodes with tree, reply, link, and advance edge types), upserting it at the top of the timeline for client rendering.

Participant Child Sessions and Approval Proxying

  • Read-only default and writable roles: Each participant is backed by a real child Session on the same Node. Any role without canEdit: true spawns with read_only = true: ResolveDiscussionMode() (server/node/session/policy.go) picks a true read-only mode when available (Codex read-only, OpenCode plan) or an ask-each-time mode otherwise (Claude default plus --disallowedTools Edit,Write,NotebookEdit), with read-only checks handled automatically by readonly_policy.go (see Multi-Agent Orchestration). Roles declaring canEdit: true are not marked read-only and follow normal Approval rules.
  • Approval bubbling and cancellation: When a participant child triggers a human question or (for writable roles) a tool Approval, watchManager delivers a needs_input callback carrying pending_prompts. The Discussion Room emits a proxied Prompt card (proxy-<pid>-<itemId>) in its own timeline. Answering inside the room forwards via Conn.Answer() to the child; answering directly in the child Session triggers a cleanup callback that invalidates the proxy card automatically.
  • Operational boundaries: The Discussion Room itself does not write rows to usage_records (avoiding double-counting with participant child Sessions, while still aggregating tokens and cost live for display and budgets). It supports handoff to a regular coding Session via ExtractTurns, explicitly rejects ForkSession, RewindSession, native terminals, and UpdateSession changes to model/mode/plan/options, and archives (rather than hard-deleting) participant child Sessions when deleted.

Built-in Modes

Five built-in modes are embedded via go:embed from server/node/session/discussion/modes/ (manifest discussion-modes.json plus .star scripts), all written using the exact same Starlark primitives available to custom modes:

Mode ID Name Roles & Counts Default Budget Workflow
committee Roundtable (圆桌会诊) member (2–6) 3 rounds / 1800s Everyone answers blindly with no shared context first, followed by incremental cross-examination rounds until no pending steers remain and everyone sets STATUS=PASS or STANCE converges; the chair then synthesizes consensus, disagreements, and recommendations.
oxford Oxford Debate (正反辩论) pro (1–2), con (1–2), judge (1, chair) 3 rounds / 1800s Pro and Con present independent opening arguments, then cross-examine over multiple rounds until everyone passes; the neutral judge delivers a verdict grounded in the full exchange.
review Proposal Review (方案评审) author (1, chair), reviewer (1–4) 4 rounds / 1800s The author presents the proposal first, reviewers conduct parallel blind reviews (hidden from each other), then author and reviewers iterate until all pass or stances converge, ending with a review checklist (all read-only).
knockout Tournament (方案淘汰赛) contender (2–8), judge (1, chair) 16 rounds / 3600s Contenders face off in pairs (odd contender gets a bye); the judge picks WINNER each match, marking winner/eliminated and drawing advance edges. If the judge fails to pick a valid winner, ask_user lets you break the tie; the judge concludes with champion commentary.
moderated Host-Moderated (主持人点名) host (1, chair), member (2–6) 12 rounds / 1800s Each round the host narrows the focus and names the next speaker via NEXT (defaulting to whoever has spoken least if omitted); that member responds incrementally until the host returns DONE: true (or names the same speaker consecutively), followed by the host's summary.

Three-Tier Configuration and Starlark Scripts

A discussion mode consists of a JSONC manifest plus a Starlark script, re-read live from disk on every mode listing or room creation (server/node/session/discussion/modes.go).

Override Precedence

Entries sharing the same id override from lowest to highest priority: Built-in < User-level < Repository-level:

  1. Built-in: Embedded server/node/session/discussion/modes/discussion-modes.json.
  2. User-level: <node-root>/discussion-modes.json (default ~/.trizano/node/discussion-modes.json).
  3. Repository-level: <workspace>/.trizano/discussion-modes.json (can be committed to Git and shared with teammates).

Notes: Manifests use JSONC (comments and trailing commas allowed, standardized with hujson.Standardize and validated strictly with protojson; top-level keys are limited to $schema and modes). Each mode validates independently—an error in one mode attaches the raw error to that card without breaking other modes. When a room is created, its manifest metadata and script source are frozen into DiscussionConfig.mode_snapshot, so later edits never affect existing rooms.

Starlark Primitives and Standard Helper Library

The Starlark dialect enables while, recursion, set, and global reassignment (no try/except, class, or f-strings—use "%s" % x). Every script must define top-level def run(room): and may optionally define def finale(room)::

  • Read-only fields: room.topic, room.participants, room.chair, room.by_role(id), room.entries, room.rounds, room.cost, room.elapsed, room.budget (max_rounds, max_wall_seconds, max_cost_usd), and room.steers. Participant exposes id/name/role/agent/model; Entry exposes id/participant/stage/text/fields (missing fields return None).
  • Blocking actions:
    • room.ask(who, prompt, see="new", outputs={}, parallel=True, group="") -> list[Entry]: see accepts "none", "new" (incremental), "all", list[Entry], or a filter function fn(participant). outputs declares trailing <!-- discussion-meta --> structured fields ("text", "number", "bool", or an enum list), parsed fault-tolerantly by the engine.
    • room.ask_user(question, options=[]) -> struct(choice, text): Emits a question card in the room and pauses the wall-clock budget while waiting for your response.
    • room.say(text): Posts a moderator notice in the timeline.
  • Display primitives: room.stage(name) switches stages; room.link(a, b, label="", kind="link") adds cross edges ("link" or "advance"); room.mark(entry, state) marks an entry "winner", "eliminated", or "highlight".
  • Built-in helper module: load is restricted to @trizano//discussion.star, which exports all_pass(entries), converged(entries, key="STANCE"), majority(entries, key), count(entries, key, value), and can_stop(room).

Minimal repository-level manifest and script example:

// <workspace>/.trizano/discussion-modes.json
{
  "modes": [
    {
      "id": "quick-pair",
      "title": "Pair Review",
      "description": "Independent analysis first, one cross-review round, then chair wrap-up.",
      "script": "modes/quick_pair.star",
      "roles": [
        { "id": "member", "label": "Member", "minCount": 2, "maxCount": 4, "prompt": "Focus on code evidence and concrete risks." }
      ],
      "defaults": { "maxRounds": 2, "maxWallSeconds": 900 }
    }
  ]
}
# <workspace>/.trizano/modes/quick_pair.star
load("@trizano//discussion.star", "all_pass", "can_stop")

META = {"STANCE": "text", "STATUS": ["CONTINUE", "PASS"]}

def run(room):
    room.stage("Blind Draft")
    room.ask(room.participants, "Independently propose an approach and list key risks.", see = "none", outputs = META)
    room.stage("Cross Review")
    res = room.ask(room.participants, "Challenge or supplement the other proposals; set STATUS to PASS if you have no objections.", outputs = META)
    if can_stop(room) and all_pass(res):
        return

def finale(room):
    room.stage("Synthesis")
    room.ask(room.chair, "Synthesize both perspectives into a concrete action plan.", see = "all")

CLI and MCP Entry Points

Agents and users can drive Discussion Rooms and debug custom modes via trizano-h3 discuss (server/cmd/trizano-h3/orch_cli.go) and the built-in MCP tools (server/cmd/trizano-h3/mcp.go).

Room Runtime Commands (In-Session Orchestration Channel)

CLI Subcommand MCP Tool Key Flags & Behavior
discuss start trizano_discuss_start --preset <id> (default committee), --topic, --title, --workspace, repeatable --participant agent[:model[:role[:name]]] or --participants-json, --max-rounds, --max-wall-seconds, --max-cost-usd, --chair, --watch, --note
discuss post <ref> trizano_discuss_post --text (supports @participant), --steer (mid-turn steer), --summarize (stop further rounds and run finale immediately), --watch, --note
discuss read <ref> trizano_discuss_read Read room status, participants, structured entries, chair summary, and pending prompts
discuss stop <ref> trizano_discuss_stop Interrupt the currently running discussion round
# Start a roundtable discussion with --watch to wake the parent Session on completion
"$TRIZANO_CLI" discuss start \
  --preset committee --title "Caching strategy evaluation" \
  --participant claude::member:Architect \
  --participant codex::member:PerfReviewer \
  --watch \
  --topic "Evaluate replacing the current in-memory cache with SQLite WAL."

# Steer mid-run, trigger early summary, and read results
"$TRIZANO_CLI" discuss post sessions/<id> --steer --text "Also account for Windows file-locking differences."
"$TRIZANO_CLI" discuss post sessions/<id> --summarize --watch
"$TRIZANO_CLI" discuss read sessions/<id>

Mode Debugging Tool: trizano-h3 discuss modes

discuss modes runs locally and requires no session token, so you can invoke it from any shell or agent Session:

# List all resolved modes for the current Node and Workspace (including source tier and errors)
trizano-h3 discuss modes [--root <node-root>]

# Print the full embedded custom-mode authoring guide (bundled in the binary; read on demand)
trizano-h3 discuss modes --guide

# Dump any mode's manifest entry and Starlark script for copying and customization
trizano-h3 discuss modes --dump committee

# Statically validate user-level and Workspace manifests/scripts (JSONC, fields, roles, Starlark resolve, def run; non-zero exit on error)
trizano-h3 discuss modes --check

# Zero-token dry run using the real engine with mock participants; prints stage trace, per-speaker visibility, and an ASCII graph
trizano-h3 discuss modes --dry-run my-mode --participants claude,codex,opencode --seed 42

Creating and Editing Modes in the Web UI

Discussion Room setup page

Note

The Trizano UI is currently in Chinese. Labels below show the English meaning followed by the exact Chinese text shown in the interface.

The Web client places discovery and launch on the New Session screen and editing/live validation inside the built-in IDE (currently editing repository-level .trizano/ only; existing rooms are unaffected because their snapshot is frozen):

  1. Mode grid and card menu (web/src/components/DiscussionSetup.tsx):
    • Switching to Discussion Room (「讨论室」) calls ListDiscussionModes, displays source badges (Built-in 「内置」 / User 「用户」 / Repo 「仓库」 / Customized 「已自定义」 when overriding a built-in) and writable badges (Writable 「可写」), and renders a schematic flow graph via PreviewDiscussion (400 ms debounce).
    • Opening the ⋯ menu on any valid card offers:
      • Built-in modes: Customize this mode (「自定义此模式」, calls CreateDiscussionMode(override=true) to create a same-ID override in .trizano/ and opens the IDE) and New mode based on this (「基于此新建模式」).
      • Repo modes: Edit in IDE (「在 IDE 中编辑」), New mode based on this (「基于此新建模式」), and Restore default / Delete mode (「恢复默认」/「删除模式」, DeleteDiscussionMode).
      • User-level modes: Copy to current repo to edit (「复制到当前仓库以编辑」).
    • Broken repo mode cards render greyed out with the raw error and a Fix in IDE (「在 IDE 中修复」) button jumping straight to the failing manifest or script line.
  2. Create custom mode dialog (web/src/components/DiscussionModeCreateDialog.tsx):
    • Clicking the dashed New custom mode (「新建自定义模式」) card at the end of the grid opens a two-tab dialog:
      • Have an agent write it (「让智能体帮我写」): Describe the desired workflow in plain language and click Open IDE to start writing (「打开 IDE 开始编写」); Trizano pre-fills the IDE chat draft with a task specifying --guide, --check, and --dry-run verification and opens the IDE.
      • Create manually from template (「手动从模板创建」): Pick the Blank skeleton (「空白骨架」, embedded modes/skeleton.star) or any valid mode as a template, enter a title and ID, and click Create and open in IDE (「创建并在 IDE 中打开」). The Node appends to the manifest via hujson patch (preserving existing comments and formatting), writes .trizano/modes/<id>.star, and opens it in the IDE.
  3. IDE mode preview bar (web/src/components/ide/DiscussionModePreviewBar.tsx):
    • Appears automatically when opening .trizano/discussion-modes.json or any referenced .star file in the IDE. On open and on every save, it re-runs ListDiscussionModes and PreviewDiscussion, showing the stage chain along with Re-run dry run (「重新试跑」), View flow graph (「查看流程图」), and Try in New Session ↗ (「去建房试用 ↗」). Errors highlight in red with clickable file/line jump links.

Clone this wiki locally