Skip to content

Composition Forum

skobeltsyn edited this page Mar 28, 2026 · 1 revision

Composition: Forum (*)

Overview

A Forum models multi-agent deliberation. Unlike Parallel where agents work independently on the same input, a Forum represents a structured discussion where agents can see and respond to each other's reasoning. You build a Forum with the * operator:

initiator * analyst * critic

The first agent's IN type defines the Forum's input. The last agent's OUT type defines the Forum's output. This gives you a typed deliberation chain where each participant's role is explicit in the type system.

Type Signature

// Two agents -> Forum
operator fun <A, B, C> Agent<A, B>.times(other: Agent<*, C>): Forum<A, C>

// Extend a Forum with one more agent
operator fun <A, B, C> Forum<A, B>.times(other: Agent<*, C>): Forum<A, C>

Notice the wildcard Agent<*, C> for subsequent agents. The Forum's type signature captures the overall input-to-output contract (Forum<A, C>), while intermediate agents can accept flexible input types since the deliberation protocol manages data flow between participants.

When to Use Forum vs Parallel

Parallel (/) Forum (*)
Execution Independent, concurrent Deliberative, agents see each other
Communication None between agents Agents respond to prior reasoning
Output List<OUT> (one result per agent) Single OUT (consensus/final answer)
Use case Fan-out: multiple perspectives on same data Debate: structured discussion toward a conclusion
Operator / *

Choose Parallel when agents do not need to know about each other (e.g., translating to multiple languages simultaneously). Choose Forum when agents should build on, challenge, or synthesize each other's outputs (e.g., a code review where the critic responds to the reviewer's findings).

Basic Example

A deliberation chain where a specification is discussed by multiple stakeholders:

import agents_engine.core.*
import agents_engine.composition.forum.times

data class Specs(val text: String)
data class Task(val specs: Specs, val text: String)
data class Opinion(val text: String)
data class Opinions(val opinions: List<Opinion>)
data class Result(val text: String)

val forumInitiator      = agent<Specs, Task>("forumStarter") {}
val opinionsArbitrage   = agent<Task, Opinions>("arbitrage") {}
val slopGenerator       = agent<Task, Opinion>("slop") {}
val passiveGenerator    = agent<Task, Opinion>("passive") {}
val answerMaster        = agent<Opinions, Result>("answer") {}

val forum = forumInitiator * opinionsArbitrage * slopGenerator * passiveGenerator * answerMaster
// forum: Forum<Specs, Result>

Composing with Pipelines

Forums integrate naturally with Pipelines. You can place a Forum as a stage inside a larger pipeline using then:

import agents_engine.composition.pipeline.then

val inputParser = agent<Input, Specs>("parser") {}
val printer     = agent<Result, String>("printer") {}

val pipeline = inputParser then
    (forumInitiator * opinionsArbitrage * slopGenerator * passiveGenerator * answerMaster) then
    printer
// pipeline: Pipeline<Input, String>

The pipeline feeds the parsed specs into the forum, and the forum's result continues to the printer.

Current Status

The Forum type structure and operator overloads are fully implemented and type-checked at compile time. However, the deliberation execution logic is not yet fully implemented. Invoking a Forum embedded in a pipeline currently throws:

error("Forum execution not yet implemented")

The type system, agent placement tracking, and composition with other primitives all work correctly today. You can define your forum topology now and the execution will work once the deliberation protocol is complete.

What works today:

  • Type-safe forum creation with *
  • Agent placement tracking (agents cannot be reused)
  • Composing forums into pipelines with then
  • Compile-time type checking of the full pipeline

What is coming:

  • The deliberation loop where agents exchange messages
  • Context passing between forum participants

Next: Pipeline | Parallel | Loop | Branch | While Loops

Clone this wiki locally