Comma Agents
@comma-agents/core

Strategy

Define agent orchestration graphs declaratively in JSON or YAML.

Strategies let you define agents, flows, and their wiring in a JSON or YAML file instead of writing TypeScript. A strategy file declares agents with their models and prompts, then wires them into a flow (sequential, cycle, or broadcast). At runtime, loadStrategy parses and validates the file, instantiates real agents and flows, and returns a runnable entry flow.

This is useful when the orchestration graph is data-driven — for example, loaded from a config file, received over a network, or generated by another tool.

Quick Start

Given a strategy file strategy.json:

{
  "name": "Code Review Pipeline",
  "version": "1.0",
  "agents": {
    "analyzer": {
      "model": "openai/gpt-4o",
      "systemPrompt": "Identify bugs and code smells. Output a numbered list (max 5)."
    },
    "reviewer": {
      "model": "openai/gpt-4o",
      "systemPrompt": "Suggest specific fixes for each issue found."
    }
  },
  "flow": {
    "name": "Review Pipeline",
    "type": "sequential",
    "steps": [
      { "agent": "analyzer" },
      { "agent": "reviewer" }
    ]
  }
}

Load and run it:

import { loadStrategy } from "@comma-agents/core";

const strategy = await loadStrategy("./strategy.json");
const result = await strategy.flow.call("Review this: function add(a, b) { return a + b; }");
console.log(result.text);

The returned flow is a standard flow — you can call it, stream it, or attach hooks via hookIntoFlow.

Sections

  • Strategy File Format — the schema for strategy files: agent definitions, flow definitions, nesting, and tools.
  • LoadingloadStrategy and loadStrategyFromString for parsing, validating, and instantiating strategy files.
  • ExportingexportStrategy for serializing a loaded strategy back to JSON or YAML.

On this page