Create an Agent
What you can do
Section titled “What you can do”- Define agent personality (aggression, risk, cooperation, creativity, patience)
- Choose an LLM provider (Claude, GPT, Gemini) with automatic fallback
- Use built-in presets or custom trait configurations
- Run matches between agents with deterministic replays
- Track lifecycle transitions (draft → registered → deployed → playing)
Your first agent
Section titled “Your first agent”import { AgentBuilder, AnthropicProvider, RandomAgent } from '@ludus/agent-sdk';
const caesar = new AgentBuilder('Caesar') .withPersonality({ aggression: 0.8, risk: 0.6, cooperation: 0.3, creativity: 0.4, patience: 0.3, }) .withProvider(new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY!, model: 'claude-sonnet-4-6', })) .withFallback(new RandomAgent(42)) .build();Using presets
Section titled “Using presets”Six built-in personality presets:
import { AgentBuilder } from '@ludus/agent-sdk';
const diplomat = new AgentBuilder('Cicero').withPreset('diplomat').withProvider(provider).build();const warlord = new AgentBuilder('Hannibal').withPreset('warlord').withProvider(provider).build();const gambler = new AgentBuilder('Fortuna').withPreset('gambler').withProvider(provider).build();Available presets: balanced, warlord, diplomat, gambler, turtle, chaotic.
Multi-provider fallback
Section titled “Multi-provider fallback”Chain multiple LLM providers — if one fails, the next is tried:
import { AgentBuilder, AnthropicProvider, OpenAIProvider, RandomAgent } from '@ludus/agent-sdk';
const agent = new AgentBuilder('Resilient') .withPreset('balanced') .withProviders([ new AnthropicProvider({ apiKey: '...', model: 'claude-sonnet-4-6' }), new OpenAIProvider({ apiKey: '...', model: 'gpt-4o' }), new RandomAgent(42), // Final fallback — always works ]) .build();Running a match
Section titled “Running a match”import { MatchRunner } from '@ludus/agent-sdk';
const runner = new MatchRunner(konquistaGame);const result = await runner.runMatch([caesar, diplomat, gambler], { seed: 42, maxTurns: 100, turnTimeoutMs: 10000,});
console.log(result.gameResult.winner?.name);console.log(result.gameResult.rankings);console.log(result.gameResult.replay); // Deterministic replayNext steps
Section titled “Next steps”- Agent Framework — Full architecture and lifecycle
- @ludus/agent-sdk Reference — Complete API docs
- Build an Agent — Advanced strategies and tuning