014 · Agents
Agents, delegation and forged tools (spec_014_agents)
| Status | Implemented. Reverse-engineered from 53f8c53 (2026-09-24) and kept with the code since; its paths checked 2026-09-27 (//tools/specs). |
| Source | pkg/engine/agents/{manager,frontmatter,files}.go, pkg/engine/agents/builtin/*.md; pkg/engine/agentfiles.go; pkg/engine/runtime/settings.go; pkg/engine/tools/{agent_tools,universal_constructor}.go; pkg/service/server/agents.go; apps/desktop/web/src/AgentEditor.tsx |
| Tests | pkg/engine/agents/*_test.go; pkg/engine/agentfiles_test.go; pkg/engine/tools/uc_and_agent_tools_test.go; pkg/engine/runtime/{pin,settings}_test.go; pkg/service/server/handlers_test.go |
| Depends on | spec_002_config, spec_007_shell, spec_005_approvals |
| Used by | spec_016_engine |
An agent is a persona: a system prompt, a tool list, an agency level and optionally its own model, defined in Markdown with YAML frontmatter. One agent is active (the root); the others are sub-agents it can delegate to. Helios can forge small tools at runtime.
- AG-01 File format:
---YAML frontmatter---then the system prompt. Frontmatter:name(required),display_name,description,tools(registry tool names, aliases allowed),default_model(provider/model),agency_level, and the model settings of AG-21. - AG-01 2026-11-05 (scan N26-engine-sub-1#1, #2, #3, #5: a misspelt key such as
permissionModeor a command’smodelwas dropped, so a reviewer meant to be read-only ran in the workspace’s mode; a---inside a value ended the front matter; a badagency_levelor name loaded as high;isolationwithoutbackgroundloaded, then everyinvoke_agentof it failed). Front matter is read strictly: a key Blitz doesn’t know is the file’s problem and the agent doesn’t load (frontmatter.Strict;lockandgroups, an organization catalog’s, are accepted). Only a---line ends it, after an optional byte order mark (frontmatter.Split). The name pattern,agency_levelandisolation: worktreewithoutbackground: trueare checked on load (AgentMetadata.Check), as on save. - AG-02 Prompts may contain
{agency_instructions}or{{agency_instructions}}, replaced by the rules for the level (empty = high):- low — one step at a time; after each meaningful unit, stop, summarise and ask; no consequential or irreversible action without explicit approval.
- medium — do routine, clearly requested work; check in at major milestones or before consequential changes.
- high (default) — complete the task autonomously; ask only when blocked by missing requirements or irreversible actions needing approval.
- extreme — maximal persistence; don’t stop while a background process gates completion; check progress.
- AG-03 The root agent uses the configured
blitz.agency_level(changeable with/set agency=); sub-agents use their own frontmatter level. - AG-04 2026-10-22. Each turn is the agent the run asks for: the active agent, or a command’s (
agent:in its frontmatter, such as/spec,/skills updateand/reflect), whoever answered before. The other agents are the root’s sub-agents fortransfer_to_agent, built never to transfer back (DisallowTransferToParent), so the ADK runner, which otherwise hands the next turn to the agent that answered last, falls back to the root. A transfer lasts the rest of its turn. Before, once a conversation had a turn, a command’s agent and a switch with/agentwere ignored and the last agent kept answering (TestTheAskedAgentAnswersAfterHistory,TestTransferLastsTheTurn). - AG-45 2026-11-15 (the owner: an agent is “meta-data (system instructions, model, model properties) and required skills … versioned assets … an agent may depend on skill version 1, while another agent depends on version 2”).
skills:names the skills an agent needs, each by a version range:name,name@1.x, or{name: …, version: …}(spec_065_packages PK-02, PK-03); a name or range that doesn’t read, or a skill named twice, keeps it from loading. An organization’s library resolves the ranges when the agent is published and runs it with the versions they resolved to (blitz-enterprise spec_014_library LB-02, LB-07); Blitz’s own use of them, each agent with its own versions, comes with the library’s delivery (R1).
- AG-10 Built-in agents are embedded. External agents are loaded (recursively,
*.md) from~/.blitz/agents(config.UserAgentsDir), then the workspace’s.agents/agents(config.ProjectAgentsDir, as prompt text, spec_031_project_config; a later folder wins a name), then enabled plugins’agents/. 2026-10-01: the workspace folder moved from./agentsto.agents/agents, beside.agents/workersand.agents/skills;./agentsis no longer read. External specs may add agents but may not replace a built-in (that would let a directory swap a trusted persona’s prompt and tools); rejected or unparseable specs are reported, valid ones still load. - AG-10 2026-11-05 (scan N26-pkg-small-2#1, N26-engine-sub-1#6: a plugin’s agent loaded after the organization’s locked folder took a locked agent’s name, prompt and tools; two files of one name in one folder were used in walk order without a word). An agent from the organization’s locked folder keeps its name: a later folder’s agent of that name (a plugin’s) isn’t loaded and is reported (
Registry.Lock, set before loading). Two files in one folder that define one name are reported; the later in walk order is used, and the editors’ listing gives the other the problem (agents.ListFiles). - AG-11
Listis sorted by name. - AG-13 2026-10-01. Agents reload without reopening the workspace. The registry keeps the folders it loaded and a stamp of their
*.mdfiles (path, size, modification time);Registry.Refreshreloads them when the stamp changes, keeping the built-ins.Workspace.RefreshAgentsruns it before each turn and job run and when agents or jobs are listed or an agent is switched: an added file’s agent is offered, an edited one’s prompt, tools, settings anddefault_modelapply from the next turn (models pinned or unpinned to match), and a removed one is gone (the active agent falls back toblitz). Files that don’t load are warnings. 2026-10-16:/reloadmakes the next refresh load them regardless (Registry.Invalidate), for an edit that kept a file’s size and time, and lists what didn’t load (spec_012_memory MEM-25). - AG-14 2026-10-01. Agent files are written by the editors through
WorkspaceService.ListAgentFiles,SaveAgentFileandDeleteAgentFile, per scope:AGENT_SCOPE_WORKSPACE(the workspace’s.agents/agents) orAGENT_SCOPE_USER(~/.blitz/agents, needing no workspace). Listing returns every file with what it defines or why it doesn’t load (unparseable, a built-in’s name). Saving checks the name (^[a-z0-9][a-z0-9_-]{0,63}$, not a built-in’s, not another file’s in the folder), a description, the agency level and the model settings, and returns problems with nothing written; it writes<name>.mdatomically (an edit keeps the agent’s file whatever it’s called, a rename moves it to the new name’s file), and the workspace named reloads at once. Writing a file drops YAML comments and keys Blitz doesn’t know.
| Built-in | Role | Agency |
|---|---|---|
blitz |
Primary agent (default): code, documents, research and data; makes small changes itself and hands substantial code changes to coder (AG-14a) |
high |
coder |
Coding specialist: reads, changes, runs and verifies code, loading the language skills for the workspace’s stack | high |
helios |
Universal Constructor: forges and runs tools | high |
qa |
Tests, TDD, regression suites, edge cases | high |
web-retriever |
Documentation and web research | high |
planning-agent |
Requirement decomposition, roadmaps, verification gates (read-only tools + invoke_agent) |
medium |
agent-creator |
Creates and validates agent specs and skills | high |
model-judge |
Compares model responses | medium |
project-setup |
Sets up a workspace’s agent harness: interviews, .agents/AGENTS.md, the instruction files importing it, skills and agents (/setup, spec_012_memory MEM-22) |
medium |
project-spec |
Writes and revises the project’s specification in .agents/specs/ after an interview on intent, users, performance, platform and security (/spec, MEM-42) |
medium |
harness-update |
Revisits the skills or agents against the specification (/skills update, /agents update, MEM-44) |
medium |
- AG-12 Built-in prompts are persona-free and terse (no mascot, plain status marks).
- AG-14a 2026-10-28 (the owner’s request).
blitzis a generalist, not a coding agent: it works out what a task needs, does small things itself (a line or two, a setting, a document) and hands a substantial code change tocoderwithinvoke_agent, giving the goal, the files involved, what it found and what done looks like.codercarries Blitz’s working rules word for word (terse; small focused changes, DRY, YAGNI, tests with behaviour changes; files under about 600 lines; read before editing; targeted diffs;command -v, neverfind), whichblitzkeeps too, so the code is as good whoever writes it (TestEmbeddedRegistryholds them in both). Before changing code,coderloads the skills for the stack it sees (go.mod,pyproject.toml,package.json): the built-ingo,python,python-uv,reactand, withplaywright.config.*,playwright(spec_013_skills SK-01). Languages are skills, not agents: a task crosses languages, and one more agent is one more routing choice. A sub-agent withactivate_skillgets the skill index offered to it in its instruction, as the primary agent does (skillIndex,subInstructioninpkg/engine/runtime/engine.go). Asked about the project (where the work stands, what’s left, the spec),blitzlooks before answering (.agents/specs/, its instructions,git log, the code) and never says it has no access or context: a small model (qwen2.5-coder:7b) answered "Where are we on the tasks?" with "I don’t have any information" though the harness was in its prompt. A greeting, small talk or a thank-you gets a sentence of plain text with no tools, inblitz’s prompt and inask_user_question’s description (“not for conversation”): small local models (seen withqwen2.5-coder:7b) answered “Hi, how are you?” with a question form. The engine’s own prompts (compaction, the reviewer, hooks, goals, the agent drafter, next-step ideas) say “an AI agent”, not “a coding agent”.
- AG-21 2026-10-01. An agent’s frontmatter may set
temperature(0–2),top_p(above 0, at most 1),max_tokens(at least 1),effort(minimal, low, medium, high, max;xhighreads as max) andthinking_budget(0 or more). They apply to that agent’s model calls only, as the main agent or a sub-agent, over the model’s own[model_settings]and the session’s effort; settings it leaves unset stay the model’s. Settings the provider can’t take are dropped as for[model_settings](spec_016_engine). The model is wrapped when the agent is built (withAgentSettings), and the settings travel in the call’s context to the model’s settings wrapper. - AG-20 An agent runs on (highest first): an
[agent_models]pin, its owndefault_model, the configured model. Pinned agents keep the fallback chain behaviour of their own model and are priced by it./pin_model <agent> <model>and/unpin <agent>change pins live and in the config file (spec_018_workspace WS-41).doctorchecks each pin.
- AG-30
list_agents(filter?)→ name, display name, description (substring filter). - AG-31
invoke_agent(agent_name, prompt, background?)→ the sub-agent’s final text (response) orerror; withbackground: true(or the agent’s ownbackground: truewhen the call doesn’t say) it returns at once with atask_idand the sub-agent runs as a task (spec_032_background_agents). An agent’s frontmatter may also setpermission_mode(its own mode throughinvoke_agent; a looser one than the workspace’s only for built-in agents, the user’s own and a trusted project’s; bypass only in the OS sandbox) andmax_turns(its own model-call budget). The sub-agent runs in a fresh isolated session, gets the MCP servers offered to it, and nesting is capped at depth 3 (spec_016_engine ENG-70). In plan/read-only runs the sub-agent is equally restricted. - AG-14b 2026-11-06 (the owner: asked for an image with
gemini-4-argon,blitzlisted the workspace’s files and fed them to the model: “That’s not a coding task”).blitzfits the work to the request: a picture, a document, an answer or research needs no look at the code or the file tree. Exploring withlist_filesandglobis for a task that works on the workspace’s files, not a rule before every task, and the engineering rules are for when it changes code. Asked for a picture, it draws withgenerate_image(spec_006_filetools FS-80) and gives the path; without that tool (no image model set) it says so in a sentence, naming the workspace’s Image model setting and[images] model, and doesn’t explore instead.TestEmbeddedRegistryholds these lines. - AG-14c Search-first and targeted-window discovery. The built-in
blitz,coderandplanning-agentprompts instruct the model to locate where a concept or symbol is handled first withsearch_workspace(which returns recommendedlinesranges, spec_035 SRCH-41a),grep(usingmode: "files_only"or"count"when broad, spec_006 FS-84), orlsp, and to passstart_lineandend_linetoread_filewhen reading large files (>500 lines, FS-83b). - AG-31a 2026-10-29 (the owner: “the checklist doesn’t seem to update” during /setup). A sub-agent run in the foreground shows its work in the conversation as it happens (
runtime.WithSubagentEvents): its tool calls and results under its name (Event.Author), and its task list in the checklist; when it returns, the calling agent’s own list is shown again. Its words reach only the agent that asked (the tool’sresponse), so they aren’t shown or kept as the conversation’s. Every final event of it is kept in the session’s sub-agent log,<session>.subagents.jsonl, owner-only and deleted with the session, since its own session is in memory. A background task’s events go to the task, as before (BGA). - AG-31b Distilled sub-agent response (spec_016_engine ENG-70c):
invoke_agentreturns only the sub-agent’s final model turn text (omitting intermediate prose emitted before tool calls during the sub-agent’s loop), capped at 8,000 characters, andsubInstructioninstructs delegated sub-agents to end with a concise summary (what changed or was found, how it was verified, and any open issues).
Args: action (create|run|list|delete), tool_name, language (bash/sh, python/py, go; default bash), code, description, args (whitespace-separated).
- AG-40 Tool names match
^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$(no separators or traversal). Tools are stored intools.uc_tools_dir(default~/.blitz/uc_tools, created lazily) as the script plus a JSON manifest (name, language, description, created); the script path is never stored — it is recomputed from the validated name and language. - AG-41
createneeds write approval (kindwrite_file);deleteneeds delete approval (kinddelete_file);listreturnsname (language): description. - AG-42
run: the command policy sees the synthetic commanduniversal_constructor <tool> <args…>(shell-quoted, so allow-lists must opt in with e.g.universal_constructor *); deny blocks; otherwise approval unless auto-approved (kindrun_command, keyuc-run:<tool>\x00<args…>, “this forged tool with these arguments”). Runs asbash <script>,python3 <script>orgo run <script>through the exec environment (OS sandbox, scrubbed env, process guard), 60 s timeout, 100 KiB output. - AG-42a 2026-11-05 (scan N26-engine-tools-2#7: forging was a file edit that accept-edits let through unasked, and a run approved “always” was keyed on the name and arguments only, so the tool could be forged again with other code and run under the old approval).
createis approved as a command (ActionCommand), so accept-edits asks about it (bypass and auto-approved commands still let it through), and a run’s approval key holds the script’s SHA-256:uc-run:<name>\x00<sha256>\x00<args…>, so changed code is asked about again. - AG-43 Manifests are untrusted on reload: name and language are re-validated and the script must be a regular file (not a symlink) at the derived path. Forged tools persist across sessions.
- AG-44 2026-10-18. An agent’s tools are exactly its list: with none it can only reply. A new agent made in the desktop app starts with tools to read, search and change the workspace’s files, the web, asking the user and skills (
starterTools: no commands, which are added on purpose), and the editor warns when an agent has no tools.