A configurable, spec-compliant analysis worker for AgentCompose.
It scores options against weighted criteria over supplied evidence and returns a ranked,
decision-ready verdict with a recommendation — behind the capability analyze. It is a
general evaluator: competitive analysis and feasibility are criteria presets, not
separate agents. You can score vendors, designs, PRs, or product ideas with the same machine.
npm install @agentcompose/analysis-agentIt consumes evidence rather than gathering it — pair it downstream of the research worker for fresh data:
graph LR
R[research<br/>gather] --> A[analyze<br/>score + rank + recommend] --> P[HITL pick]
import { makeAnalysisAgent } from "@agentcompose/analysis-agent";
import { inProcess } from "@agentcompose/sdk";
const analysis = makeAnalysisAgent({
defaults: { baseUrl: "http://localhost:4000/v1", model: "gpt-4o-mini" },
});
const client = inProcess(analysis);
await client.configure({ preset: "feasibility" });
const task = await client.submit([
{ kind: "text", text: "Evaluate the feasibility of building each as a solo dev in 4 weeks." },
{ kind: "json", json: { options: ["Habit tracker", "Multiplayer game", "Notes PWA"] } },
]);
for await (const ev of client.events(task.id)) {
if (ev.type === "result" || ev.type === "error") break;
}
const final = await client.get(task.id);
// → [ { kind:"text", markdown decision brief }, { kind:"json", Analysis } ]A structured Analysis (the json part) plus a Markdown decision brief (the text part)
and an analysis.md artifact:
interface Analysis {
subject: string;
criteria: Criterion[];
scale: number; // scores run 0..scale
options: OptionScore[]; // { name, scores, notes, weightedScore }
ranking: string[]; // option names, best first
recommendation: { choice; confidence: "low"|"medium"|"high"; rationale };
risks: string[];
}Scoring is deterministic and reproducible. The model only assigns raw per-criterion magnitudes (grounded in the evidence); the worker computes the weighted, normalized total in code — honoring weights and inverted ("lower is better") criteria. The model is never trusted for arithmetic or for picking the winner.
| Key | Default | Description |
|---|---|---|
preset |
competitive |
competitive, feasibility, or custom (then supply criteria). |
criteria |
— | Explicit weighted criteria; override/extend the preset by name. { name, weight?, description?, invert? }. |
scale |
10 |
Score scale upper bound (0..scale). |
maxOptions |
6 |
Cap on options when they're extracted from the evidence. |
options |
— | Explicit options to evaluate; omitted → extracted from the evidence. |
evidence |
— | Inline evidence (in addition to evidence passed in the goal). |
provider |
— | BYO-model: { baseUrl, model, apiKey } (OpenAI Chat Completions compatible). |
A criterion with invert: true (e.g. cost, technical effort, risk) is one where a
high score is bad — the worker subtracts it from the scale before weighting, so a costly
or risky option ranks lower. Presets ship sensible weights; override any by name:
await client.configure({
preset: "competitive",
criteria: [{ name: "demand", weight: 3 }, { name: "novelty", weight: 1 }],
});"Competitive Analyst" and "Feasibility scorer" are not separate agents — they are the same
analyze capability with different criteria presets. New evaluation verticals are config, not
code, which keeps the worker general and composable.
Apache-2.0