Logo: Agent Squad Typescript

Agent Squad Typescript

OrganisatiounBeléift
2FastLabs
agent-squad-typescript

Use when building or modifying a Node.js / TypeScript app that uses the agent-squad npm package — multi-agent orchestration: orchestrator, agents (all built-in types + GroundedAgent), classifier routing (Bedrock / Anthropic / OpenAI), storage (in-memory / DynamoDB / SQL), retrievers (Amazon KB / Dakera), and tools (AgentTools + MCPToolProvider).

Iwwersiicht

Editeur2FastLabs
Repositoryagent-squad
Skill-Nummagent-squad-typescript
Stären
7.8K
Forks
741
Matgeliwwert Dateien
64
LizenzApache-2.0
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 64 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    2FastLabs huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Agent Squad Typescript an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/2FastLabs/agent-squad/tree/main/typescript
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/2FastLabs/agent-squad.git /tmp/agent-squad
mkdir -p .claude/skills
cp -r /tmp/agent-squad/typescript .claude/skills/agent-squad-typescript
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Agent Squad Typescript an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Agent Squad Typescript automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Agent Squad Typescript net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

agent-squad TypeScript — assistant guide

Node.js / TypeScript multi-agent orchestration framework (npm package agent-squad). All public symbols are exported from a single barrel typescript/src/index.ts. This file is guidance and a map — not an API reference. Read exact signatures from typescript/src/ and worked recipes from docs/src/content/docs/; this file tells you what to use, when, and what to watch out for.

When to use what

  • One assistant → a single Agent subclass + AgentSquad with no routing. Or skip the orchestrator entirely and call agent.processRequest(...) directly.
  • Several specialists → multiple agents registered with orchestrator.addAgent(agent), a classifier routes each turn.
  • Answers must not drift from data (prices, balances, live lookups) → GroundedAgent: a gatherer LLM calls tools, an isolated presenter LLM speaks only from the curated results.
  • Fixed pipeline → ChainAgent: each agent's output is the next agent's input.
  • One lead LLM coordinating a team → SupervisorAgent: the lead calls sub-agents as tools.
  • External tools via MCP → MCPToolProvider (async factory pattern, optional peer dep).
  • RAG context → attach a Retriever to any agent that supports retriever? in its options.

How to install

bash
npm install agent-squad

Optional peer dependencies — install only what you use:

PackageUsed by
@aws-sdk/client-bedrock-runtimeBedrockLLMAgent, BedrockClassifier (already a hard dep in current releases)
@anthropic-ai/sdkAnthropicAgent, AnthropicClassifier (already a hard dep)
openaiOpenAIAgent, OpenAIClassifier (already a hard dep)
@modelcontextprotocol/sdkMCPToolProvider — lazy await import() at connect time
@dakera-ai/dakeraDakeraRetriever — lazy require() at construction time

@modelcontextprotocol/sdk and @dakera-ai/dakera are the only two true optional peer deps; everything else ships as a hard dependency at the moment.

How a turn works

routeRequest is the single entry point. It classifies the input, dispatches to the selected agent, saves the exchange, and returns an AgentResponse. The response is either a plain string or a Node.js Transform stream:

typescript
import { AgentSquad, BedrockLLMAgent, BedrockClassifier } from 'agent-squad';

const orchestrator = new AgentSquad({
  classifier: new BedrockClassifier(),   // default when omitted
  // storage: new DynamoDbChatStorage(...),
  // config: { LOG_AGENT_CHAT: true, MAX_MESSAGE_PAIRS_PER_AGENT: 50 },
});

orchestrator.addAgent(new BedrockLLMAgent({
  name: 'Tech Support',
  description: 'Handles technical questions about software and hardware',
  streaming: true,
}));

const response = await orchestrator.routeRequest(
  userInput,
  userId,
  sessionId,
  additionalParams   // optional Record<string, any>
);

if (response.streaming) {
  // response.output is an AccumulatorTransform (Node.js Transform)
  for await (const chunk of response.output) {
    process.stdout.write(chunk);
  }
} else {
  // response.output is a string
  console.log(response.output);
  // response.thinking? is set when the agent used extended thinking
}

// response.metadata: { agentId, agentName, userId, sessionId, userInput, additionalParams }

routeRequest never throws — it catches all errors and returns them as a non-streaming AgentResponse with the error string in output (configurable via GENERAL_ROUTING_ERROR_MSG_MESSAGE).

The pieces

Orchestrator: AgentSquad

typescript
new AgentSquad(options?: OrchestratorOptions)

Key OrchestratorOptions fields:

FieldDefaultNotes
classifiernew BedrockClassifier()Any Classifier subclass
storagenew InMemoryChatStorage()Any ChatStorage subclass
defaultAgentundefinedUsed when classifier returns no match and USE_DEFAULT_AGENT_IF_NONE_IDENTIFIED is true
config.USE_DEFAULT_AGENT_IF_NONE_IDENTIFIEDtrueFall back to defaultAgent or return NO_SELECTED_AGENT_MESSAGE
config.MAX_MESSAGE_PAIRS_PER_AGENT100Per-agent history cap (pairs = user+assistant)
config.MAX_RETRIES3Classifier retries on bad XML response
config.LOG_AGENT_CHATfalse

Useful methods: addAgent(agent), setDefaultAgent(agent), getDefaultAgent(), getAllAgents(), analyzeAgentOverlap(), classifyRequest(...), agentProcessRequest(...).

The classifier is exposed as a public field (orchestrator.classifier) so its system prompt can be overridden after construction.

Agents

All agents extend Agent and require at minimum { name, description } in their options.

agent.id is derived automatically from name: non-alphanumeric stripped, spaces → hyphens, lowercased. "Tech Support" → "tech-support". This is the key used for storage and classifier matching — it must be stable across restarts.

ClassOptions typeNotes
BedrockLLMAgentBedrockLLMAgentOptionsBedrock Converse API; supports streaming, modelId, inferenceConfig, guardrailConfig, reasoningConfig, retriever, toolConfig, customSystemPrompt, client, callbacks
AnthropicAgentAnthropicAgentOptionsDirect Anthropic SDK; similar options shape
OpenAIAgentOpenAIAgentOptionsOpenAI Chat Completions
AmazonBedrockAgentAmazonBedrockAgentOptionsAmazon Bedrock Agents (pre-built agents, not Converse)
BedrockInlineAgentBedrockInlineAgentOptionsBedrock inline agents
BedrockFlowsAgentBedrockFlowsAgentOptionsBedrock Flows
LambdaAgentLambdaAgentOptionsInvokes a Lambda function as an agent
LexBotAgentLexBotAgentOptionsAmazon Lex V2 bot
ChainAgentChainAgentOptionsFixed pipeline; agents: Agent[], defaultOutput?
SupervisorAgentSupervisorAgentOptionsLead + team; leadAgent must be BedrockLLMAgent or AnthropicAgent; lead must have no toolConfig (SupervisorAgent manages tools)
GroundedAgentGroundedAgentOptions2-LLM anti-hallucination; gatherer, presenter, tools, curator?, presenterPrompt?

AgentOptions base fields: name (required), description (required), saveChat? (default true), logger?, LOG_AGENT_DEBUG_TRACE?.

BedrockLLMAgent toolConfig shape:

typescript
toolConfig: {
  tool: AgentTools | Tool[],   // AgentTools instance or raw Bedrock Tool array
  useToolHandler: (response: any, conversation: ConversationMessage[]) => any,
  toolMaxRecursions?: number,
}

When using MCPToolProvider, pass it as toolConfig.tool and omit useToolHandler — the provider overrides toolHandler internally.

GroundedAgent

Two-LLM anti-hallucination pattern. The gatherer calls tools; the presenter receives only the curated facts (never raw tool output, never chat history from the gatherer):

typescript
import {
  GroundedAgent, DataBlockCurator, PerToolCurator, PresenterPrompt,
  BedrockLLMAgent, AgentTools, AgentTool,
} from 'agent-squad';

const tools = new AgentTools([
  new AgentTool({ name: 'get_price', description: '...', func: async ({ sku }) => fetchPrice(sku) }),
]);

const gatherer = new BedrockLLMAgent({ name: 'Gatherer', description: '...', toolConfig: { tool: tools, useToolHandler: ... } });
const presenter = new BedrockLLMAgent({ name: 'Presenter', description: '...' });

const agent = new GroundedAgent({
  name: 'Price Agent',
  description: 'Answers pricing questions grounded in live data',
  gatherer,
  presenter,
  tools,
  curator: new DataBlockCurator(),          // default; or PerToolCurator for per-tool formatting
  presenterPrompt: PresenterPrompt.default(), // generic grounding prompt; or per-tool map
});

A no-tool turn (chit-chat) is answered by the gatherer directly, skipping the presenter.

Classifiers

ClassOptions typeNotes
BedrockClassifierBedrockClassifierOptionsDefault when no classifier is passed to AgentSquad
AnthropicClassifierAnthropicClassifierOptions
OpenAIClassifierOpenAIClassifierOptions

All classifiers support setSystemPrompt(template?, variables?) to override the routing prompt. Template variables use {{VAR_NAME}} syntax; AGENT_DESCRIPTIONS and HISTORY are always injected automatically.

Storage

ClassNotes
InMemoryChatStorageDefault; non-persistent; fine for dev and tests
DynamoDbChatStorageRequires @aws-sdk/client-dynamodb and @aws-sdk/lib-dynamodb (hard deps)
SqlChatStorageRequires @libsql/client (hard dep); works with Turso or local libsql
SummarizingChatStorageWraps any storage; compresses history via a user-supplied ChatSummarizer callable when fetchChat returns more than triggerAt * 2 messages; cache-based save-back

Storage is keyed by (userId, sessionId, agentId). fetchAllChats(userId, sessionId) is used by the classifier to get cross-agent history for context.

Retrievers

ClassOptions typeNotes
AmazonKnowledgeBasesRetrieverAmazonKnowledgeBasesRetrieverOptionsAmazon Bedrock Knowledge Bases
DakeraRetrieverDakeraRetrieverOptionsDakera memory server; optional peer dep @dakera-ai/dakera

DakeraRetrieverOptions: namespace (required), apiKey? (falls back to DAKERA_API_KEY env), url? (falls back to DAKERA_URL then http://localhost:3000), topK? (default 10), filter?.

Attach to a BedrockLLMAgent via retriever: option. The agent calls retriever.retrieveAndCombineResults(inputText) to augment its system prompt.

DakeraRetriever.retrieveAndGenerate() always throws — Dakera is retrieval-only.

Tools: AgentTools and AgentTool

typescript
import { AgentTools, AgentTool } from 'agent-squad';

const myTools = new AgentTools([
  new AgentTool({
    name: 'search_web',
    description: 'Search the web for current information',
    properties: {
      query: { type: 'string', description: 'The search query' },
    },
    required: ['query'],
    func: async ({ query }) => webSearch(query),
  }),
]);

AgentTool constructor will auto-extract parameter names from func if properties is omitted — but this is fragile with minification. Always pass explicit properties and required.

MCPToolProvider

MCPToolProvider extends AgentTools. Always use the async factory — never new MCPToolProvider(...) directly — so that tool definitions are fetched before the agent makes its first API call:

typescript
import { MCPToolProvider } from 'agent-squad';

const provider = await MCPToolProvider.create([
  { type: 'stdio', command: 'uvx', args: ['my-mcp-server'] },
  { type: 'sse', url: 'http://localhost:3000/sse', headers: { Authorization: 'Bearer tok' } },
]);

const agent = new BedrockLLMAgent({
  name: 'MCP Agent',
  description: 'Agent with MCP tools',
  toolConfig: { tool: provider },
});

// Clean up when done (closes stdio processes and SSE connections)
await provider.disconnect();

MCPServerConfig.type is "stdio" or "sse". For stdio: command is required, args? and env? are optional. For sse: url is required, headers? is optional.

MCPToolProvider overrides toBedrockFormat(), toAnthropicFormat(), and toOpenAIFormat() to pass MCP inputSchema through unchanged rather than re-serializing it.

Requires npm install @modelcontextprotocol/sdk. The SDK is imported lazily via await import() inside ensureConnected() — installing agent-squad without the SDK is safe as long as you don't instantiate MCPToolProvider.

Custom implementations

Extend the abstract base class and pass your type where the built-in goes.

SeamBase classMethod to implementSource
AgentAgentprocessRequest(inputText, userId, sessionId, chatHistory, additionalParams?) returns Promise<ConversationMessage | AsyncIterable<any>>typescript/src/agents/agent.ts
ClassifierClassifierprocessRequest(inputText, chatHistory) returns Promise<ClassifierResult>typescript/src/classifiers/classifier.ts
StorageChatStoragesaveChatMessage, fetchChat, fetchAllChatstypescript/src/storage/chatStorage.ts
RetrieverRetrieverretrieve, retrieveAndCombineResults, retrieveAndGeneratetypescript/src/retrievers/retriever.ts

ClassifierResult shape: { selectedAgent: Agent | null, confidence: number }.

Classifier base class provides setAgents, setHistory, setSystemPrompt, and getAgentById(agentId) — use getAgentById in your processRequest to look up the selected agent from the classifier's registered map.

Gotchas

  • agentId is derived from name at construction time: non-alphanumeric stripped, spaces replaced with -, lowercased. Changing an agent's name changes its id, which breaks chat history lookups in storage. Keep names stable across deployments.

  • Streaming response is a Node.js Transform stream, not an async generator. Check response.streaming before iterating. The transform accumulates the full response internally; for await (const chunk of response.output) works because Transform implements AsyncIterable. Do not call response.output.read() manually.

  • routeRequest never throws. Errors are returned as non-streaming AgentResponse with the error string in output. If you need to distinguish errors from real responses, check response.metadata.errorType === 'classification_failed' or inspect metadata.agentId.

  • MCPToolProvider.create(...) must be awaited before the agent is used. The constructor alone does not connect; calling processRequest before create resolves means tool definitions are empty and the agent will behave as if it has no tools.

  • BedrockClassifier is the default. If boto3/AWS credentials are not configured and you don't pass an explicit classifier, AgentSquad will construct a BedrockClassifier that will fail at runtime. Pass classifier: new AnthropicClassifier(...) or new OpenAIClassifier(...) if you're not on AWS.

  • Optional peer deps use lazy import/require. MCPToolProvider uses await import(...) inside ensureConnected(); DakeraRetriever uses require(...) inside the constructor. Neither adds a top-level import, so a missing peer dep is only discovered at instantiation time — not at module load. Throw the missing-dep error early, before user input arrives.

  • SupervisorAgent restrictions: leadAgent must be BedrockLLMAgent or AnthropicAgent; the lead agent must have no toolConfig set (SupervisorAgent wires its own tool loop). Pass additional native tools via extraTools.

  • saveChat defaults to true. Every agent persists both sides of each exchange after the turn completes. Set saveChat: false on agents that should not write to storage (e.g. a presenter inside a GroundedAgent that is managed externally).

  • additionalParams flows through routeRequest → dispatchToAgent → agent.processRequest. Use it to pass per-request context (tenant ID, request ID, feature flags) without touching agent options. The values end up in response.metadata.additionalParams.

  • AgentTools auto-extracts parameter names from func via .toString(). This breaks with minification and TypeScript arrow functions with destructured arguments. Always supply explicit properties and required arrays to AgentTool.

  • ThinkingResponse: when a BedrockLLMAgent is configured with reasoningConfig, the non-streaming path may return response.thinking (a string) alongside response.output. The streaming path does not surface thinking tokens separately.

Go deeper

  • Prose & recipes — docs/src/content/docs/ (run the site from docs/ with npm run dev): orchestrator/overview, agents/built-in/bedrock-llm-agent, agents/built-in/grounded-agent, classifiers/overview, storage/overview, retrievers/overview, tools/mcp.
  • Exact signatures — typescript/src/ (orchestrator.ts, agents/, classifiers/, storage/, retrievers/, tools/mcpToolProvider.ts, utils/tool.ts, types/index.ts).
  • Tests — typescript/tests/ for usage patterns and mock strategies (virtual mocks for optional peer deps via jest.mock(..., { virtual: true })).
  • Barrel — typescript/src/index.ts is the definitive list of every public symbol.

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

An nach 4 weider Dateien.

Heefeg gestallte Froen

Wat mécht de KI-Skill Agent Squad Typescript?

Use when building or modifying a Node.js / TypeScript app that uses the agent-squad npm package — multi-agent orchestration: orchestrator, agents (all built-in types + GroundedAgent), classifier routing (Bedrock / Anthropic / OpenAI), storage (in-memory / DynamoDB / SQL), retrievers (Amazon KB / Dakera), and tools (AgentTools + MCPToolProvider).

Firwat Agent Squad Typescript op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Agent Squad Typescript besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Agent Squad Typescript an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/2FastLabs/agent-squad/tree/main/typescript an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Agent Squad Typescript benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Agent Squad Typescript benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Agent Squad Typescript domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Agent Squad Typescript gratis?

Jo. 2FastLabs huet de Skill ënner der Lizenz Apache-2.0 op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇