features/agents/extending

A guide for adding a new provider backend to a coding-agent system. A backend is the code that connects the system to a particular agent service or command.

In plain words
What is it for?
Building a new agent provider, translating model, effort, and budget settings, parsing streamed output, and registering the backend.
Why use it?
It shows which provider-specific parts to implement while leaving shared validation, events, and lifecycle behaviour in the existing core.

Agent

Part of the fractal plugin — 4 skills, 4 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/plasma-ai/fractal/extending
Clone the repo
git clone --depth 1 https://github.com/plasma-ai/fractal

Or install fractal, the plugin that ships this one along with the rest of its 4 skills, 4 agents.

Per session 5 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 787 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00005 $0.00787
Opus 5 $0.00003 $0.00394
Sonnet 5 $0.00001 $0.00157
Haiku 4.5 $0.00001 $0.00079

Measured 3d ago against content hash bf8f457b1117, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

features/agents/extending scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

wiki/features/agents/extending.md · 74 lines

How it starts

The opening of the file, as written. The whole thing — 74 lines — stays where its author put it; the contents beside it link to each section on GitHub.

features/agents/extending

[[features/agents/_index|..]]


Agent invocation is a deliberate core/impl seam: fractal/core/agent.py defines the base class and the registry, and each provider lives in one fractal/impl/ module. A new backend is therefore one new module plus one registry entry — nothing in core/, cli/, or tui/ changes.

The subclass shape

Backends override only _-prefixed hooks and capability attributes; the public verbs own validation, event emission, and the settle invariants. The public/private pairing is uniform: the public verb (invocation, spawn, preflight, seeding, session and cost recording) validates and emits, then delegates to its private hook, which the subclass implements:

  • the invocation hook builds the provider argv for a fresh, resumed, or forked session, spelling the model, effort, and budget overrides in the provider's dialect and returning any provider-specific environment keys (a key valued None means unset — that is how a native route scrubs an ancestor route's keys from the composed spawn environment);
  • the parser is a stream-parser subclass fed the subprocess's output line by line, emitting typed stream events (session, cost, actions); a backend may swap parsers per route;
  • the configured-model and rates hooks back cost accounting: the former resolves the model the provider's own config defaults to, the latter maps a model to its pricing;
  • the transcript hook (with its fallback) locates a session's transcript file — the seam the project-files surface fronts (see [[features/files/transcripts]]);
  • the preflight hook probes provider readiness before a run commits;
  • the seeding hook materializes the provider's config directory in a new node, receiving the parent node's data directory so files an inherited config references — codex's relative model instructions file — travel with the config copy.

Capability declarations — session forking, who mints session ids, cost scope, pricing needs, budget enforcement, result-frame cadence, and the provider route list — are class attributes read by the base class; see [[features/agents/providers]] for their meaning.

Read the full file on GitHub · 74 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 74 lines · 5 tokens per session scan A bf8f457b1117

Subscribe to this mod's changes

features/agents/extending is an agent published in the GitHub repository plasma-ai/fractal (704 stars, last pushed 4d ago), licensed Apache-2.0. It adds 5 tokens to every session and 787 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.