/** * Agent Discussion -- durable round-robin debate compiled to a Conductor DoWhile loop. * * Demonstrates a multi-turn discussion between agents with opposing * viewpoints using the round_robin strategy. The entire debate runs * server-side as a Conductor DoWhile loop -- durable, restartable, and * observable in the Conductor UI. After the discussion, a summary agent * distills the transcript into a balanced conclusion via the .pipe() * pipeline operator. * * Flow (all server-side): * DoWhile(6 turns): * turn 0 -> optimist * turn 1 -> skeptic * turn 2 -> optimist * ... * summarizer produces conclusion * * Requirements: * - Conductor server with LLM support * - CONDUCTOR_SERVER_URL=http://localhost:8080/api * - CONDUCTOR_AGENT_LLM_MODEL=openai/gpt-4o-mini */ import { Agent, AgentRuntime } from '@io-orkes/conductor-javascript/agents'; import { llmModel } from './settings'; // -- Discussion participants -------------------------------------------------- export const optimist = new Agent({ name: 'optimist', model: llmModel, instructions: 'You are an optimistic technologist debating a topic. ' + 'Argue FOR the topic. Keep your response to 2-3 concise paragraphs. ' + "Acknowledge the other side's points before making your case.", }); export const skeptic = new Agent({ name: 'skeptic', model: llmModel, instructions: 'You are a thoughtful skeptic debating a topic. ' + 'Raise concerns and argue AGAINST the topic. ' + 'Keep your response to 2-3 concise paragraphs. ' + "Acknowledge the other side's points before making your case.", }); export const summarizer = new Agent({ name: 'summarizer', model: llmModel, instructions: 'You are a neutral moderator. You have just observed a debate ' + 'between an optimist and a skeptic. Summarize the key arguments ' + 'from both sides and provide a balanced conclusion. ' + 'Structure your response with: Key Arguments For, ' + 'Key Arguments Against, and Balanced Conclusion.', }); // -- Round-robin discussion: 6 turns (3 rounds of back-and-forth) ------------- export const discussion = new Agent({ name: 'discussion', model: llmModel, agents: [optimist, skeptic], strategy: 'round_robin', maxTurns: 6, }); // Pipe discussion transcript to summarizer const pipeline = discussion.pipe(summarizer); // -- Run ---------------------------------------------------------------------- async function main() { const runtime = new AgentRuntime(); try { const result = await runtime.run( pipeline, 'Should AI agents be allowed to autonomously make financial decisions for individuals?', ); result.printResult(); // Production pattern: // 1. Deploy once during CI/CD (optional -- serve() below also deploys): // await runtime.deploy(pipeline); // CLI alternative: // conductor deploy --package examples/agents --agents discussion // // 2. In a separate long-lived worker process (deploys + registers workers + starts polling): // await runtime.serve(pipeline); } finally { await runtime.shutdown(); } } main().catch(console.error);