What you'll build

  • Understand the four FAHRN execution modes
  • Run a Parallel pipeline across three AI providers simultaneously
  • Build a Debate pipeline where agents challenge each other's reasoning
  • Use Voting mode to select the best response by consensus
  • Wire up a SkillOpt self-improving agent with outcome feedback

The Four FAHRN Execution Modes

ModeHow it worksBest for
SerialAgents run one after another. Output of agent N is input of agent N+1.Pipelines: draft โ†’ review โ†’ refine โ†’ format
ParallelAll agents run simultaneously. Results collected and merged.Speed: generate multiple answers fast, pick the best
DebateAgents argue for/against a proposition over multiple rounds. A judge agent synthesises the winner.High-stakes decisions, legal / medical review, trust document analysis
VotingAgents vote on a ranked set of answers. Plurality or weighted-karma winner selected.Creative tasks: choose the best story, dialogue or plan by consensus

Serial Pipeline

serial-pipeline.js
import { ai } from './web6.js';

const { result } = await ai.fahrn.run({
  mode: 'Serial',
  agents: [
    {
      name:     'Drafter',
      provider: 'openai',
      model:    'gpt-4o',
      systemPrompt: 'Draft a first version of the answer.',
    },
    {
      name:     'Critic',
      provider: 'anthropic',
      model:    'claude-3-5-sonnet',
      systemPrompt: 'Identify flaws and gaps in the draft. Be harsh.',
    },
    {
      name:     'Refiner',
      provider: 'google',
      model:    'gemini-pro',
      systemPrompt: 'Produce a polished final answer addressing all criticisms.',
    },
  ],
  input: 'Explain how OASIS HyperDrive auto-failover works.',
});

console.log('Final answer:', result.finalOutput);

Parallel Pipeline

parallel-pipeline.js
const { result } = await ai.fahrn.run({
  mode: 'Parallel',
  agents: [
    { name: 'OpenAI',    provider: 'openai',     model: 'gpt-4o'            },
    { name: 'Anthropic', provider: 'anthropic',  model: 'claude-3-5-sonnet' },
    { name: 'Google',    provider: 'google',     model: 'gemini-pro'        },
  ],
  input: 'Generate a unique quest name for a volcanic planet.',
  mergeStrategy: 'bestOf',   // 'concat' | 'bestOf' | 'custom'
});

// result.outputs contains one response per agent
result.outputs.forEach(o => console.log(o.agentName, ':', o.content));

Debate Mode

Debate is the most powerful mode for high-stakes decisions. Agents argue across multiple rounds before a judge synthesises a final verdict.

debate-pipeline.js
const { result } = await ai.fahrn.run({
  mode:   'Debate',
  rounds: 3,
  agents: [
    {
      name:     'Advocate',
      provider: 'openai',
      model:    'gpt-4o',
      systemPrompt: 'You argue IN FAVOUR of the proposition. Be persuasive.',
    },
    {
      name:     'Opposition',
      provider: 'anthropic',
      model:    'claude-3-5-sonnet',
      systemPrompt: 'You argue AGAINST the proposition. Find flaws.',
    },
  ],
  judge: {
    provider: 'google',
    model:    'gemini-ultra',
    systemPrompt: 'You are an impartial judge. Weigh the arguments and give a final verdict.',
  },
  input: 'Should the Crimson Key NFT be transferable between games?',
});

console.log('Verdict:', result.judgeVerdict);
console.log('Winning side:', result.winner);

Voting Mode

voting-pipeline.js
const { result } = await ai.fahrn.run({
  mode: 'Voting',
  agents: [
    { name: 'Agent1', provider: 'openai',    model: 'gpt-4o'            },
    { name: 'Agent2', provider: 'anthropic', model: 'claude-3-5-sonnet' },
    { name: 'Agent3', provider: 'meta',      model: 'llama-3-70b'       },
    { name: 'Agent4', provider: 'mistral',   model: 'mistral-large'     },
  ],
  votingMethod: 'plurality',   // 'plurality' | 'ranked' | 'karma-weighted'
  input: 'What should the final boss of the Key Hunters quest be called?',
});

console.log('Winning answer:', result.winner);
console.log('Vote breakdown:', result.votes);

SkillOpt โ€” Self-Evolving Agents

SkillOpt agents record outcome feedback and use it to refine their own system prompts over time. Each run improves the next.

skillopt.js
// Create a SkillOpt agent โ€” it self-refines based on feedback
const { result: agent } = await ai.skillOpt.createAgent({
  name:         'QuestNarrator',
  initialPrompt: 'You write engaging quest narratives for the OASIS.',
  provider:     'openai',
  model:        'gpt-4o',
});

// Run the agent
const { result: run } = await ai.skillOpt.run({
  agentId: agent.id,
  input:   'Write an intro for the Crimson Key mission.',
});

// Feed back outcome โ€” agent learns from this
await ai.skillOpt.recordOutcome({
  runId:   run.id,
  score:   0.9,   // 0โ€“1
  feedback: 'Great dramatic tone. Too long โ€” trim by 20%.',
});
๐Ÿ’ก
Debate mode is how Leela works in SovereignTrust

The SovereignTrust legal assistant uses FAHRN Debate mode with three AI providers cross-checking each other's trust document interpretation before surfacing the final advice to the user.