Skip to main content

Overview

Reminix supports serving multiple agents from a single project. This is useful when you have related agents that share dependencies or need to be deployed together.

When to Use Multiple Agents

Use multiple agents when:
  • You have specialized agents for different tasks (e.g., summarizer, translator, classifier)
  • Agents share common dependencies or configuration
  • You want to deploy and scale related agents together
  • You’re building a multi-agent system with orchestration
Use separate projects when:
  • Agents have different scaling requirements
  • Agents have conflicting dependencies
  • Teams work independently on different agents
  • Agents need separate deployment lifecycles

Basic Example

Serve multiple agents from one server:
import { agent, serve } from '@reminix/runtime';

// Agent 1: Summarizer
const summarizer = agent('summarizer', {
  description: 'Summarize text',
  input: {
    type: 'object',
    properties: { text: { type: 'string' } },
    required: ['text']
  },
  handler: async ({ text }) => `Summary: ${(text as string).slice(0, 100)}...`
});

// Agent 2: Translator
const translator = agent('translator', {
  description: 'Translate text',
  input: {
    type: 'object',
    properties: {
      text: { type: 'string' },
      target: { type: 'string' }
    },
    required: ['text']
  },
  handler: async ({ text, target }) => `Translated to ${target || 'es'}: ${text}`
});

// Agent 3: Classifier
const classifier = agent('classifier', {
  description: 'Classify text',
  input: {
    type: 'object',
    properties: { text: { type: 'string' } },
    required: ['text']
  },
  handler: async () => ({ category: 'general', confidence: 0.95 })
});

// Agent 4: Chat assistant
const assistant = agent('assistant', {
  template: 'chat',
  description: 'A conversational assistant',
  handler: async ({ messages }) =>
    `You said: ${(messages as Array<{ content?: string }>).at(-1)?.content ?? ''}`
});

// Serve all agents on one server
serve({ agents: [summarizer, translator, classifier, assistant], port: 8080 });

With Framework Adapters

When using framework adapters like LangChain or Vercel AI, use wrapAgent + serve instead of serveAgent:
import { ChatOpenAI } from '@langchain/openai';
import { createOpenAIFunctionsAgent, AgentExecutor } from 'langchain/agents';
import { wrapAgent } from '@reminix/langchain';
import { serve } from '@reminix/runtime';

// Create your LangChain agents
const llm = new ChatOpenAI({ model: 'gpt-4o' });

const researchAgent = await createOpenAIFunctionsAgent({ llm, tools: researchTools, prompt: researchPrompt });
const researchExecutor = new AgentExecutor({ agent: researchAgent, tools: researchTools });

const writingAgent = await createOpenAIFunctionsAgent({ llm, tools: writingTools, prompt: writingPrompt });
const writingExecutor = new AgentExecutor({ agent: writingAgent, tools: writingTools });

// Wrap each agent
const research = wrapAgent(researchExecutor, 'research-agent');
const writer = wrapAgent(writingExecutor, 'writing-agent');

// Serve all agents together
serve({ agents: [research, writer], port: 8080 });
Use serveAgent for single-agent projects and wrapAgent + serve for multi-agent projects.

Calling Specific Agents

When you have multiple agents, specify which agent to call by name:
import Reminix from '@reminix/sdk';

const client = new Reminix();

// Call the summarizer agent (API uses input/output only)
const summary = await client.agents.invoke('summarizer', {
  input: { text: 'Long article content...' }
});
console.log(summary.output);

// Call the translator agent
const translation = await client.agents.invoke('translator', {
  input: { text: 'Hello world', target: 'es' }
});
console.log(translation.output);

// Call the chat assistant
const response = await client.agents.invoke('assistant', {
  input: { messages: [{ role: 'user', content: 'Hello!' }] }
});
console.log(response.output);

Agent Discovery

The /info endpoint returns all available agents:
curl http://localhost:8080/info
{
  "agents": [
    {
      "name": "summarizer",
      "type": "agent",
      "input": { ... },
      "output": { ... },
      "streaming": false
    },
    {
      "name": "translator",
      "type": "agent",
      "input": { ... },
      "output": { ... },
      "streaming": false
    },
    {
      "name": "assistant",
      "type": "agent",
      "template": "chat",
      "input": { ... },
      "output": { ... },
      "streaming": false
    }
  ]
}

Naming Conventions

Use clear, descriptive names for your agents:
// Good - descriptive and specific
const summarizer = agent('document-summarizer', { ... });
const translator = agent('text-translator', { ... });
const classifier = agent('sentiment-classifier', { ... });

// Avoid - too generic
const agent1 = agent('agent1', { ... });
const agent2 = agent('agent2', { ... });

Shared Resources

Agents in the same project can share resources:
import OpenAI from 'openai';
import { agent, serve } from '@reminix/runtime';

// Shared client
const openai = new OpenAI();

// Shared configuration
const MODEL = 'gpt-4o';

const summarizer = agent('summarizer', {
  description: 'Summarize text using GPT-4',
  input: {
    type: 'object',
    properties: { text: { type: 'string' } },
    required: ['text']
  },
  handler: async ({ text }) => {
    const response = await openai.chat.completions.create({
      model: MODEL,
      messages: [{ role: 'user', content: `Summarize: ${text}` }]
    });
    return response.choices[0].message.content;
  }
});

const translator = agent('translator', {
  description: 'Translate text using GPT-4',
  input: {
    type: 'object',
    properties: {
      text: { type: 'string' },
      target: { type: 'string' }
    },
    required: ['text', 'target']
  },
  handler: async ({ text, target }) => {
    const response = await openai.chat.completions.create({
      model: MODEL,
      messages: [{ role: 'user', content: `Translate to ${target}: ${text}` }]
    });
    return response.choices[0].message.content;
  }
});

serve({ agents: [summarizer, translator], port: 8080 });

Project Structure

Recommended structure for multi-agent projects:
my-agents
src
index.ts
agents
summarizer.ts
translator.ts
classifier.ts
shared
config.ts
clients.ts
package.json
tsconfig.json
.env.example
// src/index.ts
import { serve } from '@reminix/runtime';
import { summarizer } from './agents/summarizer';
import { translator } from './agents/translator';
import { classifier } from './agents/classifier';

const port = parseInt(process.env.PORT || '8080');
serve({ agents: [summarizer, translator, classifier], port });

Mixing Frameworks

Mixing agents from different frameworks (e.g., LangChain + OpenAI adapter) is technically possible but not officially supported. For best results, use a single framework per project.
// Possible but unsupported - use at your own risk
import { wrapAgent as wrapLangChain } from '@reminix/langchain';
import { wrapAgent as wrapOpenAI } from '@reminix/openai';
import { serve } from '@reminix/runtime';

const langchainAgent = wrapLangChain(executor, 'langchain-agent');
const openaiAgent = wrapOpenAI(client, 'openai-agent');

// This works, but is not officially supported
serve({ agents: [langchainAgent, openaiAgent], port: 8080 });

Next Steps