Tool system
About 10745 wordsAbout 36 min
This document covers how to author a tool, the attribute system, naming conventions, and how tools reach the LLM.
Authoring a Tool
A tool is a final PHP class that extends AbstractTool and declares its identity, operations, parameters, and settings as PHP attributes. The base class composes HasOperations (operation dispatch) and HasParameterSchema (auto-generated JSON Schema), so a minimal tool is just execute() + describeAction().
use Spora\Tools\AbstractTool;
use Spora\Tools\Attributes\Tool;
use Spora\Tools\Attributes\ToolOperation;
use Spora\Tools\Attributes\ToolParameter;
use Spora\Tools\ValueObjects\ToolResult;
#[Tool(
name: 'web_search',
description: 'Search the web.',
displayName: 'Web Search',
category: 'research',
icon: 'search', // bundled icon key (optional; see below)
)]
#[ToolOperation(name: 'search', description: 'Run a search', enabledByDefault: true, requiresApprovalByDefault: false)]
#[ToolParameter(name: 'query', type: 'string', description: 'The search query.', required: true)]
final class MyWebSearchTool extends AbstractTool
{
public function execute(array $arguments, int $agentId, ?int $taskId = null, ?PrincipalContext $context = null): ToolResult
{
$query = trim((string) ($arguments['query'] ?? ''));
// ...
return new ToolResult(true, "Results for {$query}");
}
public function describeAction(array $arguments): string
{
return "Search the web for: '{$arguments['query']}'";
}
}That’s it — no hand-written getParametersSchema(). The ToolParameterSchemaBuilder reads the #[ToolOperation] and #[ToolParameter] attributes via reflection and produces the JSON Schema sent to the LLM.
Where ownership comes from
The $context passed into execute() is sourced by the Orchestrator from the calling Agent’s row (PrincipalResolver::resolveForToolExecute($agentId) at app/Agents/Orchestrator.php:533), not from the session. The dispatcher cannot thread a session-derived user id into a tool — the call site does not accept one. Tools therefore never need to treat ownership as “whoever is signed in”: $context->ownerUserId is “the owner of the agent that issued this call”. When the Orchestrator boots without a resolvable agent row, PrincipalContext::isResolvable() is false and ownerUserId is 0; the tool’s own getAgentByAgentId() fallback applies. See Concepts → Architecture → Orchestrator Loop for the structural guarantee.
There is no raw ?int $userId parameter any more — it was removed in spora-core PR #288, and getting the arity wrong is fatal at class-load in both directions, so core and every installed plugin move together.
The auto-synthesized action discriminator
When a tool declares two or more #[ToolOperation] attributes, the builder prepends a property to the schema (named after the first operation’s discriminatorKey, default 'action') whose enum lists every declared operation name. Do not also write #[ToolParameter(name: 'action', ...)] — the builder owns that property.
#[ToolOperation(name: 'list_events', description: 'Fetch upcoming events')]
#[ToolOperation(name: 'create_event', description: 'Create an event')]
// Auto-generated:
// properties.action = {type: string, enum: ['list_events', 'create_event'], description: '...'}
// required = ['action']Single-op tools skip discriminator synthesis — the LLM has no choice to make, and HasOperations::getOperationName() falls back to the one declared operation when the argument is absent.
To use a different discriminator key (e.g. 'operation' for parity with an external API), declare it on every #[ToolOperation]:
#[ToolOperation(name: 'search', ..., discriminatorKey: 'operation')]
#[ToolOperation(name: 'top_news', ..., discriminatorKey: 'operation')]Parameter declaration order is significant
The order in which #[ToolParameter] attributes appear on the class determines:
- The property order in the JSON Schema sent to the LLM.
- The render order of fields in the approval UI (the
parameter_schemafield ontool_callsAPI responses carries this order to the frontend).
Put the most important parameters first.
Inheritance
#[ToolParameter] declared on a parent class is inherited by subclasses for schema generation — ToolParameterSchemaBuilder walks the class hierarchy when collecting #[ToolParameter] attributes. Use this for shared parameter sets:
#[ToolParameter(name: 'name', type: 'string', description: '...', required: false)]
#[ToolParameter(name: 'content', type: 'string', description: '...', required: false)]
abstract class AbstractMemoryTool extends AbstractTool { /* shared CRUD */ }
#[Tool(name: 'memory', description: 'Agent-scoped memory.')]
#[ToolOperation(name: 'list', ...)] #[ToolOperation(name: 'get', ...)]
#[ToolOperation(name: 'save', ...)] #[ToolOperation(name: 'delete', ...)]
final class AgentMemoryTool extends AbstractMemoryTool { protected function getScope(): string { return 'agent'; } }The concrete AgentMemoryTool schema includes action, name, and content automatically.
Note on
#[ToolOperation]:HasOperationsreads operation attributes only from the concrete class — it does not walk parent classes. Always declare#[ToolOperation]on the concrete tool class, otherwise dispatch will fail to resolve operations advertised by an inherited schema.
#[Tool] reference
| Field | Type | Notes |
|---|---|---|
name | string | LLM-facing name — snake_case, /^[a-z][a-z0-9_]*$/. Plugin tools are auto-prefixed with <plugin-slug>: on the wire. |
description | string | Sent to the LLM. |
displayName | ?string | Operator-facing label; falls back to the class basename when omitted. |
category | string | One of 'general' (default), 'research', 'communication', 'productivity', 'data', 'system'. Drives the agent-tools UI grouping. |
icon | ?string | Bundled icon key (e.g. 'calendar', 'mail', 'search', 'globe'). Layer 1 of the icon resolution chain; falls back to the owning plugin’s plugin.json#icon and finally to 'puzzle'. |
recommendsSkills | ?array<string> | Optional list of skill slugs this tool bundles with. When the operator enables the tool, the agent-tools UI offers to also activate SkillTool and add these slugs to its allowed_skills. Slugs must match the agentskills.io pattern (lowercase, alphanumeric + hyphen, 1–64 chars, no leading/trailing hyphen, no --). Default []. See Bundled skills. |
#[ToolParameter] reference
| Field | Type | Notes |
|---|---|---|
name | string | Argument key the LLM sends. |
type | string | One of string, number, integer, boolean, array, object. |
description | string | Sent to the LLM. |
required | bool|list<string> (default true) | true/false keep the global behaviour; a non-empty list of operation names binds the parameter to those operations only — e.g. required: ['format'] makes the param required when the dispatcher is format. required: [] is coerced to true; use false for the truly optional case. |
default | mixed (default null) | Emitted as JSON Schema default. When set, the parameter is omitted from required[] regardless of the required flag. |
enum | list<string> | Value allowlist (string types). |
minimum / maximum | int|float|null | Numeric bounds. |
format | ?string | JSON Schema format hint (e.g. 'date', 'email'). |
items | ?array | Sub-schema for array types, e.g. ['type' => 'string']. |
Worked example: required: list<string>
TimeTool::epoch is shared across operations but required only by format, so it uses a per-operation binding:
#[ToolParameter(
name: 'epoch',
type: 'integer',
description: 'Unix timestamp to format.',
required: ['format'],
)]The generated schema requires epoch when the action dispatcher is format, while leaving it optional for other operations.
Plugin tools
Plugin tools can either extends AbstractTool like core tools, or — if they need to extend a third-party base class — opt in via:
use Spora\Tools\Traits\HasOperations;
use Spora\Tools\Traits\HasParameterSchema;
final class MyPluginTool extends ThirdPartyBase implements ToolInterface
{
use HasOperations;
use HasParameterSchema;
// ...
}The schema builder works on any FQCN via reflection — no path coupling.
Bundled skills
A tool can declare that it “bundles” one or more Skills — knowledge the operator would otherwise have to remember to activate separately. The recommendsSkills argument on #[Tool] takes a list of agentskills.io slug strings; the agent-tools UI then offers to also enable SkillTool and seed its allowed_skills with those slugs when the operator turns the bundling tool on, and asks whether to clean up the allowlist when the operator turns it off again.
#[Tool(
name: 'git_workflow',
description: 'Run git operations against the operator-configured repo.',
recommendsSkills: ['git', 'conventional-commits'],
)]The intent is to make implicit dependencies explicit. A git_workflow tool that needs the git and conventional-commits skills to produce useful output should declare that on its attribute so operators do not have to read every tool’s source to wire up the right allowlist.
Strict mode is on by default. Declaring a slug that does not exist on disk (under the framework, project, or plugin scan roots) makes GET /api/v1/tools return HTTP 500 with code TOOLS_RECOMMENDS_SKILLS_MISSING for the entire operator instance until the typo is fixed — there is no soft warning and no env-flag opt-out. The trade-off is deliberate: a misconfigured plugin (declared slug, no shipped skill) is a packaging bug operators must see, not a silently empty allowlist. Core tools are validated by tests/Unit/Tools/ToolRecommendsSkillsValidationCoreTest; plugin authors should mirror the same shape over their own scanner roots — see Validation in the plugin author guide.
The full operator flow — per-skill toggle list with title-cased names, the parent-tool disable cascade that strips unique slugs while leaving SkillTool enabled, and the status refresh that keeps the SkillTool card in sync — is documented under Skills → Bundled skills on the agent tools UI.
Putting an archive image in front of the model
A tool that produces an image — a diffusion API, a screenshot, a chart — can hand the image to the model, not only to the human reading the chat. ToolResult carries a third field for that:
use Spora\Tools\ValueObjects\ToolResult;
return ToolResult::ok(
'The poster is attached to this result.',
['asset_id' => $asset->id],
[['media_id' => $asset->id, 'kind' => 'image']],
);attachments is a list of archive references, each one {media_id, kind} — the asset’s id, and the kind of block it becomes (image). The image has to be in the Media Archive for this to work, so a plugin that archives its output already has it.
What the task history persists is the reference, not the bytes. The archive’s own row is the exception: data_url storage keeps the image payload in media_assets.payload. The image is read from storage when the request is built and rendered as an image content block on the user turn after the tool result — a turn of its own, because OpenAI’s role: tool message accepts text parts only.
That turn is never image-only: a text block naming the asset leads it — [Attached asset_id=<id> (filename: …, type: …) — local URL: …] — so the model gets the asset_id back and the asset can be chained onward.
The turn follows the whole run of tool results, not just its own. A provider accepts a tool result only directly after the assistant turn that asked for it, so a user turn between two results of the same batch is a 400. With one call the turn lands immediately after its result; with several calls in one batch it lands after the last of them.
Three byte budgets apply, and they are not interchangeable. The per-asset cap is the provider’s own ceiling on the image it receives — and what it receives is the image base64-encoded, which spends four bytes on every three, so the file that fits is three-quarters of the stated limit: 20 MB on OpenAI, 10 MB on the Claude API, 5 MB on Bedrock. A row carries a further 32 MiB of image bytes (MediaImageBlocks::MAX_ROW_BYTES) — the same budget the operator-attachment path spends. And the request as a whole carries three-quarters of the provider’s request ceiling — 128 MB on the Claude API, 20 MB on Bedrock, 512 MB on OpenAI — the remaining quarter being the system prompt, the tools and the conversation text. The operator’s own attachments and the tool images share that one budget, because a request is refused as a whole when it carries more than the provider accepts.
Where the limit is checked decides what the model sees. The three budgets above are checked when the request is built, over the images that are already attached, so an image that does not fit is dropped and the call itself does not fail: the tool result’s text still reaches the model — two images over the row’s budget leave the model with the one that fits — and an image the request had no room for is announced by a note on the tool result saying the image did not fit and was not sent.
A tool that checks a limit in the call gets a refusal instead of a drop. That is what the core’s inspect_image operation does with the endpoint’s per-image ceiling: an asset over it is refused, the call fails with a message the model reads, and the image never becomes an attachment — so there is nothing for a later request to leave out.
The image stays in the task history, so it is re-sent on every subsequent turn of the conversation — until a compaction drops it, because a compaction replaces the rows it covers with a summary, until the request has no room for it, or until the asset is removed from the archive. A removed asset stops the image being sent, and the message that claimed it carries a note that says so: the note rides on the claim’s own message, so the message count and the order the provider expects are unchanged.
The result’s content still carries the weight: it is what the model reads on the next turn, so it should say what the image is and what the tool was asked for. The image rides alongside that text, not instead of it.
ToolResult::ok() gained the third argument, and the two-argument form is unchanged — a plugin that never uses the channel is unaffected, and the existing new ToolResult(true, $content, $data) construction keeps working.
The core media tool’s inspect_image operation is the reference implementation: see Media assets → inspect_image.
Tool naming
Every tool carries a unique LLM-facing name declared via the #[Tool(name:)] attribute:
#[Tool(
name: 'web_search', // snake_case, /^[a-z][a-z0-9_]*$/
description: 'Search the web.'
)]Names must match /^[a-z][a-z0-9_]*$/ (lowercase alphanumeric + underscore, starting with a letter). An InvalidArgumentException is thrown at class instantiation time if the name is invalid.
Core vs Plugin namespacing
- Core tools (built-in): sent to the LLM with their plain name, e.g.
web_search. - Plugin tools: prefixed with the plugin slug and a colon, e.g.
my-plugin:web_search.
This ensures global uniqueness — two plugins can never produce a tool name collision. The prefix is derived automatically from plugin.json and requires no changes to the plugin’s #[Tool] attribute.
Note: core tools intentionally do not use a
core:prefix. Adding it would change every tool name currently known to the LLM, breaking existing agents. Only plugin tools get the slug prefix.
Discovery from the LLM
The built-in AgentTool (app/Tools/AgentTool.php) exposes a get_available_tools operation that returns a compact, versioned JSON payload describing every registered tool on the agent. The LLM calls this operation to plan which tools to use, to identify the tool_class it needs for configure_tools, and to surface plugin_slug values for required_plugins (operator-upload path only).
Response contract (version 2)
{
"version": 2,
"count": 2,
"tools": [
{
"tool_class": "Spora\\Tools\\CalculatorTool",
"display_name": "Calculator",
"description": "Perform arithmetic calculations.",
"plugin_slug": null,
"enabled": true,
"ready_to_enable": true,
"missing_required": [],
"operations": [
{
"name": "calculate",
"description": "Evaluate an expression.",
"enabled": true,
"requires_approval": false
}
]
},
{
"tool_class": "Spora\\Plugins\\Tavily\\Tools\\TavilySearchTool",
"display_name": "Tavily Search",
"description": "Search the web via Tavily.",
"plugin_slug": "tavily",
"enabled": false,
"ready_to_enable": false,
"missing_required": ["api_key"],
"operations": [
{
"name": "search",
"description": "Run a search.",
"enabled": true,
"requires_approval": false
}
]
}
],
"skills": {
"allowed": ["time-arithmetic"],
"visible": [
{
"name": "time-arithmetic",
"description": "Answer questions about dates, times and durations.",
"active": true
},
{
"name": "agent-creation",
"description": "Create and configure a sub-agent end to end.",
"active": false
}
]
}
}Field semantics
tool_classis the FQCN the LLM passes verbatim intoconfigure_tools.tools[].tool_class. Don’t invent FQCNs — only registered classes can be enabled.plugin_slugisnullfor core tools, the plugin slug (e.g."tavily") for plugin-owned tools, and the plugin slug for tools registered by the operator’sapp/App.phpextension. Use it forrequired_plugins[]on the operator-upload path; never substitute the FQCN.display_nameanddescriptionare kept onget_available_toolsfor operator-facing browsing, but dropped from the slim per-tool manifest returned byread_agent/configure_tools/update_agent(the LLM already hastool_class— carrying descriptive metadata bloats every LLM turn). The slim shape is{ tool_class, icon, enabled, operations[] }.enabledmirrors the currentagent_toolsrow presence.ready_to_enableistruewhen no required settings are missing. A tool withenabled: false, ready_to_enable: falseneeds configuration before the operator can enable it; the agent cannot enable it on its own.missing_requiredlists only the required setting keys; no effective values are exposed to avoid leaking credentials.operations[]carries per-operationenabled/requires_approvalstate, resolved against the effective override (or the operation’senabledByDefault/requiresApprovalByDefaultwhen no override exists).skills.allowedis the agent’s ownallowed_skillslist — the names it may load right now.skills.visibleis every skill the executing principal can see, each{name, description, active}.activeistruewhen that name is inskills.allowed. The two lists are deliberately separate: folding them together would put names in the same array whether or not the agent holds them, and the model would read array membership as the answer to “may I load this?”.
Note:
skills.visibleis the legal name set for asettings.allowed_skillswrite.configure_toolsrefuses any skill name not present in it — the whole call, not just the offending entry, because a list that quietly shrank reads to the model as the whole list landing. Readskills.visiblefirst, then name from it. The check fails closed: a provider that scopes by principal sees nothing and every name is refused.
The tools[] entry shape
{
"agent_id": 42,
"tools": [
{
"tool_class": "Spora\\Tools\\SkillTool",
"enabled": true,
"settings": { "allowed_skills": ["time-arithmetic", "agent-creation"] },
"operations": [{ "name": "list", "enabled": true, "auto_approve": false }]
}
]
}settings is optional; so are enabled and operations. Omit a key and it changes nothing. The three semantics that are easy to get wrong:
- A
settingswrite replaces the value at that key wholesale — it does not merge and it does not append. Sendingallowed_skills: ["time-arithmetic"]over an existing["time-arithmetic", "agent-creation"]leaves you with exactly["time-arithmetic"]. Always send the complete list you want to end up with. (Other keys on the same tool are untouched — it is per-key replacement, not a whole-object overwrite.) - A
settingswrite lands at the AGENT level, and that breaks inheritance. The value is written toagent_tool_overrides, which is the last-wins layer of the cascade, so the agent stops inheriting whatever the group or user scope holds for that key. To go back to inheriting, sendnullor""for the key — an empty value drops the agent-level row entirely and the cascade resumes from the layer below. allowed_skillsisstring[]of skill names;allowed_target_agentsisint[]of agent ids. The shape follows the setting’sresolveAs:SkillTool::allowed_skillsdeclaresresolveAs: 'skill'and stores names, whileSubAgentTool::allowed_target_agentsuses the defaultresolveAs: 'agent'and stores integer ids. Send a string where an id is expected (or vice versa) and the entry is refused — readskills.visible[].namefor the first andGET /api/v1/agentsfor the second.- A list may arrive wrapped, and it is unwrapped before it is judged. Some OpenAI-compatible providers hand over an array nested inside a
tools[]entry as{"item": [...]}rather than as a plain JSON array; MiniMax’s tool-call channel does this, and the model cannot produce the flat shape on request, so a retry gets the same wrapper.configure_toolsunwraps that envelope before it validates — both the{item: [...]}and the one-element{item: x}form. The unwrapped list must still pass validation before the write can succeed. A refusal that names the shape it received (got an object with the key(s) item, other) means the value arrived as an object with those keys — the plain{item: [...]}envelope is unwrapped first and so is judged as the list it stands for.
Two flags on a tool entry behave differently from the same flag on an operation:
enabledon a tool entry is tri-state.trueenables,falsedisables, and omitting the key leaves enablement alone — so a settings-only or operations-only entry cannot grant a tool as a side effect. A blank string is read as absent, not asfalse.enabledon an operation is not tri-state. Naming an operation turns it on;[{name: "now"}]is{name: "now", enabled: true}. To switch one off you must sendenabled: falseexplicitly — omitting it on an operation row is not “leave alone”, it is “turn on”.
Refusals are whole-call and happen before any write, so a rejected payload cannot have landed anything:
| Refused | Why |
|---|---|
An unknown settings key | Refused, whole call. Dropping it silently would leave the model believing a list landed — and it would then read a skill it still cannot. The refusal lists the valid keys. |
A type: 'password' setting | A credential is the one thing a tool call must not be able to write: the value would land in the call’s own recorded arguments, so the agent could read back the key it just set. Credentials stay operator-only, in the settings panel. |
| An operation name the tool does not declare | A dead override row is invisible in the manifest and reads as “nothing landed”. The refusal names the available operations. |
A skill name outside skills.visible | Refuses the whole call — see the note above. |
Slim two-phase agent creation
The LLM-facing agent creation flow is two-phase — create_agent does NOT accept a tools[] block. The flow is:
create_agent— slim skeletal record (name,description,system_prompt,max_steps,allow_followup,retry_after_minutes,max_retries,default_effort). Capture the returnedagent_id.configure_tools(agent_id: <id>, tools: [...])— apply the toolset. Each entry is{ tool_class, enabled?, settings?, operations: [{name, enabled?, auto_approve?}] }— see thetools[]entry shape for thesettingsandenabledsemantics.read_agent(agent_id: <id>)— verify the toolset is exactly what was wanted.
The full agent-template shape (id / version / nested agent{} / tools[] / required_plugins[]) is reserved for the operator-upload endpoint at POST /api/v1/agent-templates/import (see Agent template schema). create_agent rejects the nested-object shape with a literal “send X instead” example; see skills/agent-creation/SKILL.md for the full protocol.
/api/v1/tools response shape
GET /api/v1/tools is the admin-side registry endpoint that powers the agent-tools UI. The shape is built by ToolSchemaPresenter and includes every field the frontend needs to render a tool row plus the bundled-skill affordance:
| Field | Type | Notes |
|---|---|---|
tool_class | string | FQCN of the registered tool class. |
tool_name | string | The class basename (SubAgentTool → SubAgentTool). |
display_name | string | Operator-facing label, falls back to tool_name. |
description | string | Tool description, sent to the LLM. |
category | string | One of general / research / communication / productivity / data / system. Drives the agent-tools UI grouping. |
icon | string | null | Resolved icon key (3-layer chain — see Icon resolution). |
recommends_skills | string[] | Skill slugs this tool bundles. Default []. Powers the bundled-skill affordance. Strict-mode: if any entry does not resolve on disk, the entire endpoint short-circuits with HTTP 500 TOOLS_RECOMMENDS_SKILLS_MISSING — see Errors. |
operations | object[] | Per-operation { name, description, enabledByDefault, requiresApprovalByDefault, discriminatorKey }. |
Errors
| HTTP | Code | When |
|---|---|---|
| 500 | TOOLS_RECOMMENDS_SKILLS_MISSING | One or more recommends_skills entries do not resolve under the framework / project / plugin scan roots. The strict-mode check has no env-flag opt-out — the response shape carries the offenders under error.details.violations[] so operators can pinpoint the mismatch: |
{
"error": {
"code": "TOOLS_RECOMMENDS_SKILLS_MISSING",
"message": "2 tool(s) declare recommendsSkills slugs that are not on disk. See details for offenders.",
"details": {
"violations": [
{
"tool_class": "Spora\\Plugins\\AcmeSearch\\Tools\\AcmeSearchTool",
"tool_name": "AcmeSearchTool",
"missing": ["git", "conventional-commits"]
}
]
}
}
}The 500 affects only the list endpoint — per-tool settings (/api/v1/tools/{toolId}/settings, /user-settings) keep working, so operators can fix the underlying slug declaration without losing access to the rest of the admin UI.
Tool activation is operator-only
The agent-facing get_available_tools does not expose enable/disable operations. There is no enable_tool or disable_tool the LLM can call. To activate a tool:
- For sub-agents, call
create_agent(slim) and thenconfigure_tools(agent_id: <id>, tools: [...])— see Slim two-phase agent creation. - For the calling agent itself, the operator must enable the tool through the agent settings UI or the
POST /api/v1/agents/{id}/tools/{toolId}/enableendpoint. The{toolId}path segment is the tool’s#[Tool(name:)]value (e.g.tavily_searchorcalculator) — see Route definitions for the canonical mapping.
This split keeps tool activation on the calling agent under explicit operator control while still letting the agent self-compose a sub-agent when it needs capabilities beyond its current set.
Icon resolution
A tool may declare a ?string $icon argument on the #[Tool(...)] attribute — a kebab-case key from the bundled icon palette (e.g. 'calendar', 'mail', 'search', 'globe'). The icon is surfaced on the Agent resource (GET /api/v1/agents / GET /api/v1/agents/{id}) so the admin UI can render a matching tile for the tool, and on every ToolCall in tool_calls[] (REST + Mercure live-update) so the chat UI’s compact tool stream can render per-tool icons.
Resolution is a 3-layer chain, evaluated server-side:
- The
*Toolclass’s#[Tool(icon: ...)]argument (most specific — wins for multi-tool plugins). - The owning plugin’s
plugin.jsoniconfield (plugin-level identity — covers single-tool plugins automatically). null— the frontend<Icon>component falls back to'puzzle'.
Single-tool plugins don’t need to set #[Tool(icon: ...)] — their plugin.json icon field is enough via the layer-2 fallback. Multi-tool plugins should set both: plugin.json for the plugin’s overall identity and #[Tool(icon: ...)] per tool for the per-tool override.
Tool Settings Key Convention
Settings keys are the bare field name (e.g. api_key, http_timeout, host), scoped to the declaring tool class via its #[ToolSetting] attribute. The key is what the UI displays and what tool code reads via ToolConfigService::getEffectiveSettings(toolClass, ...).
Within the tool-settings cascade there is no shared key namespace — keys are looked up per tool class through reflection on the #[ToolSetting] attributes on that class. Two different tool classes may declare the same key name (e.g. api_key) without colliding; each resolves to its own setting on its own tool.
Worth naming the other namespace so nobody conflates them: Spora’s runtime configuration (SPORA_* keys, the settings table, the SettingsRegistry) is separate and is never scoped by tool class. SPORA_TOOL_HTTP_TIMEOUT and a tool’s own http_timeout are related by fallback, not by name.
Shared settings groups
A shared group is a class carrying ordinary #[ToolSetting] attributes plus one class-level attribute, #[SharedSettings], which declares group, label, description, icon, order and plugin. It exists so N tools needing the same credentials declare the key once and the operator fills it in once, instead of N times.
Discovery mirrors tools() / apps() / skillPaths(): an optional settingsClasses(): list<class-string> on the extension interface, fanned out by PluginLoader::settingsClasses(). There is no plugin.json change — the manifest schema is additionalProperties: false, so adding a key there would be a breaking change for every existing plugin.
Which tools consume a group is declared forward, on the tool (ConsumesSharedSettings), because a reverse index would go stale the first time someone adds a tool.
Ordering is load-bearing. The shared layer is applied to the unmerged schema defaults, before the tool’s own global row:
schema defaults < shared group < tool global < principal/group < agent overrideA cleared value falls through to the shared one. When an operator clears a tool’s own key to inherit the shared value, '' is stored; the default-fill uses !isset(), and '' is set, so an explicit branch treats a cleared secret as absent for this layer.
The shared layer stops at execute time. It does not reach ToolStatus or anything else answering “is this tool configured?” — those keep resolving without it, so a shared group never silently changes a tool’s status chip.
Groups are addressed as group:<slug> on /api/v1/tools/{id}/settings, and that route requires group-owner or group-admin — not a global admin.
SPORA_TOOL_HTTP_TIMEOUT
The default for a tool’s http_timeout, applied by HttpTimeoutResolver when the tool declares none of its own. It is a registry setting, so it can be changed in the admin UI without touching .env; a tool’s own #[ToolSetting] still overrides it per tool.
Examples:
http_timeout(declared onReadUrlTool)api_key(declared on whatever tool needs it —TavilySearchTool,WeatherApiTool, etc.)
Plugin Tools
When a tool is contributed by a plugin, the same rule applies: the key is the bare field name. The plugin declares its tool class in a PSR-4-namespaced location and the #[ToolSetting] attributes on that class drive the same per-tool resolution. No plugin.* namespace prefix is used.
Architecture: Settings Live on the Tool
Settings are declared as #[ToolSetting] PHP attributes directly on the tool class that consumes them. There are no separate “Configuration” shell classes.
Example
#[Tool(
name: 'my_search',
description: 'Search a remote API.',
)]
#[ToolSetting(
key: 'api_key',
label: 'API Key',
type: 'password',
description: 'API key for the remote search service.',
required: true,
// `scope` defaults to `'any'` so the example stays focused on the
// most common case — the field renders in every settings panel.
// See [Setting render scope](#setting-render-scope) below for the
// narrow scopes available when a setting only makes sense under a
// specific principal or agent context.
scope: 'any',
)]
#[ToolOperation(name: 'search', description: 'Search', enabledByDefault: true, requiresApprovalByDefault: false)]
#[ToolParameter(name: 'query', type: 'string', description: 'The query.', required: true)]
final class MySearchTool extends AbstractTool
{
public function __construct(
private readonly ToolConfigService $configService,
private readonly HttpClientInterface $httpClient,
) {}
public function execute(array $arguments, int $agentId, ?int $taskId = null, ?PrincipalContext $context = null): ToolResult
{
$settings = $this->configService->getEffectiveSettings(static::class, $agentId, null, $context);
$apiKey = $settings['api_key'] ?? '';
// ...
}
public function describeAction(array $arguments): string { /* ... */ }
}Why?
- Discoverability: A developer reading a tool class can immediately see what settings it needs and what parameters the LLM sends it.
- No empty shell classes: Previously, settings lived on empty
*Configurationclasses that existed only to hold attributes. This was wasteful. - Self-documenting: The
ToolControllerscans#[ToolSetting]attributes via reflection. Since they now live on the tool class itself, the API endpointGET /api/v1/toolsautomatically returns both the tool schema and its settings schema in a single response.
Exception: LLM driver settings
LLM driver settings (OpenAI/Anthropic API keys, model, base URL, etc.) are stored as a JSON blob on the llm_driver_configurations table, scoped to a per-driver LLMDriverConfiguration record, and surfaced via LLMConfigService::decodeSettings(). The driver class itself declares its settings via #[ToolSetting] on the class (see app/Drivers/OpenAICompatibleDriver.php and app/Drivers/AnthropicCompatibleDriver.php), and DriverFactory reads them when constructing a driver for an agent.
Setting cascade
ToolConfigService::getEffectiveSettings(toolClass, agentId, userId) resolves each setting in order:
- Schema defaults — the
default:value declared on the#[ToolSetting(...)]attribute, used when no row exists in any of the three tables below. - Global value (
tool_configurationstable, scoped to the tool class). - Group value (
tool_user_settings, on a row whoseprincipal_idis a group principal). - Principal value (
tool_user_settings, on a row whoseprincipal_idis the user principal). - Agent-level override (
agent_tool_overrides, when an entry exists foragentId + toolClass).
Later layers win; schema defaults fill in any keys that no layer has set. Tools never read tool_configurations directly — always go through ToolConfigService.
A plugin’s shared settings group sits below the global layer: it fills in the keys the global layer has not set, the same way the schema defaults do.
Two layers, one table
The group layer and the principal layer share tool_user_settings. The table was created for users; migration 0067 re-keyed it from user_id to principal_id, and migration 0082 restored the unique constraint on (principal_id, tool_class) — without it, two concurrent writes to the same (principal_id, tool_class) could both insert. The column value decides the layer: a principal_id pointing at a group principal is a group-level setting, one pointing at a user principal is the personal one.
The group layer is opt-in. It is only consulted when SPORA_TOOLS_GROUP_CASCADE_ENABLED is on, which is off by default so that a group’s tool settings stay on the group. With it on, the principal ids are iterated in a fixed order — the groups ascending by principal.id, the user principal last — so the user principal wins on conflict. See Environment variables → Tools.
Per-Tool Key Scoping
Settings keys are scoped to the declaring tool class. Two tools that happen to declare a setting with the same key name (e.g. both declaring api_key) do not share values — each tool resolves its own settings independently via ToolConfigService::getEffectiveSettings(static::class, ...).
This means:
- A user configures
api_keyonce on theTavilySearchToolsettings panel — that value is only used whenTavilySearchToolruns. - A different tool that also declares
api_key(e.g.WeatherApiTool) reads its own separately-storedapi_keyvalue.
The ToolConfigService::getEffectiveSettings() method resolves settings by scanning the #[ToolSetting] attributes on the requested class, then looking up each key in the global and agent-override stores for that class.
LLM Exposure (exposeToLlm)
By default, tool settings are server-side only — they influence how a tool behaves at execution time but are never sent to the LLM.
The exposeToLlm parameter on #[ToolSetting] controls whether a setting’s resolved value is included in the tool definition the LLM receives. This lets the LLM make informed decisions based on its effective configuration.
#[ToolSetting(
key: 'allowed_domains',
label: 'Allowed Domains',
type: 'text',
description: 'Comma-separated list of domains the agent is allowed to query.',
exposeToLlm: true, // included in LLM tool definition
)]
#[ToolSetting(
key: 'api_key',
label: 'API Key',
type: 'password',
exposeToLlm: false, // NOT sent to LLM (credential)
)]Default behavior
exposeToLlm defaults to false because most settings are credentials or infrastructure (hosts, ports, timeouts). Only mark exposeToLlm: true for settings that directly affect what the LLM can do — e.g. allowed recipient lists, sender addresses, toggle-able capabilities.
How it reaches the LLM
ToolConfigService::getLlmToolSettings() returns the effective (cascaded) values for all exposeToLlm: true settings on a tool. The Orchestrator appends these to the tool’s description before sending it to the LLM:
[Effective Configuration]
- Allowed Domains: example.com, internal.example.org
- From Address: agent@spora.localUnconfigured settings are shown as (not configured) so the LLM knows a capability may be unavailable.
Setting render scope
Every #[ToolSetting] declares where it can be configured via the scope: argument. The settings panel reads this metadata and renders each field only in compatible contexts, so a setting that only makes sense under a specific principal or agent context is never offered for editing where the resulting value would be meaningless or rejected at runtime.
#[ToolSetting(
key: 'allowed_target_agents',
label: 'Allowed target agents',
type: 'multi-select',
required: true,
scope: 'principal', // see matrix below
exposeToLlm: true,
)]Scope values
| scope | Admin operator defaults | User scope (/settings/tools) | Group scope (/groups/{id}/tools) | Agent override (/agents/{id}/tools) |
|---|---|---|---|---|
'any' (default) | renders | renders | renders | renders |
'principal' | hidden | renders | renders | renders |
'agent' | hidden | hidden | hidden | renders |
The picker multi-select on scope: 'principal' settings is also scoped by principal_id when rendered. The settings panel derives the principal from its own mode:
mode='user'→ the caller’s user-principal (usePrincipalsStorelookup)mode='group'→useGroupDetailStore().group.principal_id- per-agent override (
AgentToolOverrideForm) → the agent’sprincipal_id mode='global'→ no principal (and the field is hidden anyway byscope: 'principal')
The picker URL becomes GET /api/v1/agents?select=id,name&principal_id={N} so the backend AgentController::index intersection (?principal_id= ∩ visiblePrincipalIds()) only returns same-principal agents. The runtime gates that protect intra-principal semantics — SubAgentTool::sharePrincipal(), HandoverService, SubAgentService, ToolConfigSchemaInspector::fetchAgentNameMap() — are independent of this UI hint and continue to defend against tampered or stale payloads.
When to pick each value
'any'— the default. Use when the setting’s value is meaningful regardless of who owns the agent. Credentials, hosts, timeouts, and toggle capabilities all live here.'principal'— use when the picker (or the value itself) is only coherent under a specific principal. Concrete example:SubAgentTool::allowed_target_agentsis a multi-select that lists agents; the runtime LLM-side filter only ever resolves names against the source agent’s principal (ToolConfigSchemaInspector::fetchAgentNameMap()), so the picker is meaningless without one. Future tools that hold an allowlist of same-principal resources follow the same pattern.'agent'— use when the setting is tied to a specific agent identity (e.g. a unique API token that’s minted per agent). Currently no#[ToolSetting]inspora-coredeclares this scope; it’s reserved for plugin-side or future-core settings.
Backward compatibility
Existing operator-defaults allowed_target_agents rows written before this change still cascade down to users without overrides. The runtime LLM-side filter in ToolConfigSchemaInspector::fetchAgentNameMap() (app/Services/ToolConfigSchemaInspector.php) restricts the LLM-visible list to the source agent’s principal, so stale foreign ids in a pre-existing global degrade to "#id" placeholders — the same as before. The change is purely UI-side: the operator can no longer see or edit the picker at admin-defaults scope, but the data still flows.
Quick Reference: All Tool Settings Keys
| Key | Type | Tool Class | Purpose | LLM Exposed |
|---|---|---|---|---|
http_timeout | text | ReadUrlTool | Read URL HTTP timeout (seconds) | — |
“LLM Exposed ✓” means exposeToLlm: true — the setting’s effective value is included in the tool definition sent to the LLM.
The remaining tools (Calculator, CurrentTime, AgentMemory, GlobalMemory, ReadUrl, PrincipalInfo) declare no #[ToolSetting] attributes — they take their inputs entirely from the LLM’s arguments and have no infrastructure configuration to expose.
Sub-Agent tool
The sub_agent tool (app/Tools/SubAgentTool.php) is a single tool that declares three #[ToolOperation] entries on the op discriminator. sub_agent and sub_agent_continue run a child task and wait for its answer; handover delegates to another agent and does not.
| Operation | Enabled by default | Requires approval by default | Source chat | Waits for the answer |
|---|---|---|---|---|
sub_agent | yes | no | stays open | yes |
sub_agent_continue | no | no | stays open | yes |
handover | no | no | stays open | no |
Only sub_agent is on out of the box. The other two are opt-in per agent — an operator flips the operation’s toggle on the agent’s Tools tab (/agents/:id/tools) before the model can pick them. None of the three asks for approval by default; the per-agent override on the same tab puts one back behind the operator.
sub_agent — spawn a child task on the target agent and wait for it. The source task flips to AWAITING_SUB_AGENTS; a child Task with parent_task_id is created on the target agent. After every spawned child reaches a terminal state the parent’s next tick resumes with each child’s output appended as a role:'tool' history row. The parent’s result_data.spawned_sub_task_ids: list<int> is always plural — same shape for one or many children.
The child sees only the prompt. It has no access to the source history, so the prompt has to carry the goal, the facts, the decisions already taken and anything to preserve verbatim — a self-contained brief, or a delegation that starts from zero.
sub_agent_continue — send a follow-up to a child this conversation already started, and wait for the new answer. It takes task_id — the number from the earlier sub_agent result (“Sub-agent task #777”, the same number as in that result’s /tasks/777 link) — plus a prompt. A “chat id” in Spora is a task id, and /tasks/{id} is that task’s URL.
The continuation prompt does not have to be self-contained: the child kept its earlier conversation, so “change the heading to X” is a valid follow-up where the same words in a sub_agent prompt would have lost everything the child needed. Only tasks started by the same conversation may be continued — a task id this conversation never saw is refused. The child’s agent is still checked against the same allowed_target_agents allowlist, so a continuation cannot reach an agent the operator did not pre-approve.
handover — delegate to another agent, which continues in the background. The target’s task starts as a new, unrelated task and runs in parallel; the source chat stays open and ends on the agent’s own closing message, and no answer comes back from the target. data.handover.{target_task_id, target_agent_id, target_agent_name} records the delegation for the breadcrumb the chat renders.
The operation keeps the name handover even though nothing is handed over any more: agent_tool_operation_overrides rows name the operation, and renaming it would silently drop every operator’s deliberate enable. Read the name as background delegation.
The LLM-facing schema declares op as the discriminator (enum: sub_agent | sub_agent_continue | handover); an agent with only one operation enabled may omit op — OperationSchemaFilter strips the discriminator from required[] when only one op is allowed.
The tool result is what tells the model what it holds — sub_agent answers:
Sub-agent task #777 starts on agent #5. [Task #777](/tasks/777).The number in that line is the one a later sub_agent_continue names.
allowed_target_agents declares scope: 'principal', so the picker is hidden at the admin operator-defaults page where no principal context exists. The same picker renders under Settings → Tools → Sub-Agent (per-user overrides), Groups → {name} → Tools → Sub-Agent (per-group overrides), and the agent’s Tools tab (per-agent override). Existing global rows continue to cascade down; the runtime LLM-side filter in ToolConfigSchemaInspector::fetchAgentNameMap() restricts the LLM-visible list to the source agent’s principal, so stale foreign ids in a pre-existing global degrade to "#id" placeholders. See Setting render scope for the full matrix.
Reading vs writing skills
Skills are read and written by different tools on purpose, and they live in different places.
skill (read) | manage_skill (write) | |
|---|---|---|
| Ships in | spora-core | spora-plugin-custom-skills |
| Operations | read, files | create, update, delete |
| Scope | Every visible skill — shipped and custom | The execution’s principal’s custom skills only |
| Gated by | The agent’s allowed_skills | Per-call operator approval |
| Approval | none | create / update / delete all requiresApprovalByDefault: true |
| Enabled by default | yes | create and update yes; delete no |
The asymmetry is the design. Reading a skill is a read of operator- or user-authored knowledge, gated by the allowlist the operator already curates. Writing one is a config change to the principal’s instruction set — principal-scoped, approval-gated, and absent from core entirely, because core has nothing to write to.
delete ships enabledByDefault: false for the same reason write_notes_overwrite does in AgentTool: a tool that creates and updates but cannot delete generates a support path immediately, but the destructive path must not ride on the safe default. Every write records provenance: agent and snapshots the previous state for a one-step restore, and an approved write goes live — there is no draft/published gate, because the approval card is the review.
One consequence worth knowing: a write is not a read. Writing a custom skill does not put it in any agent’s allowed_skills — that is still an operator action on the agent’s Tools tab (or a group/user default). The plugin’s admin panel lists which agents currently allowlist a skill precisely because the alternative is an author asking the agent to use a skill and getting only “Skill ‘x’ is not in the allowed_skills list for this agent.”
There is no LLM-visible way to bypass the allowlist: manage_skill writes, skill reads, and the read still checks the list. See Concepts → Skills → Custom skills for the visibility rules that apply to a custom skill once it exists.
Built-in tools
The tools below ship inside spora-core (not as plugins). Operators can configure their settings, but the implementations themselves are not pluggable — every operator gets the same behavior out of the box.
ask_user_question — AskUserQuestionTool
The ask_user_question tool pauses the tick and puts a structured multiple-choice question to the operator, so the agent can ask for a decision that blocks its work instead of guessing or freeform-interrupting in chat.
| Operation | Default enabled | Default approval | Purpose |
|---|---|---|---|
ask | yes | auto | Pose 1-4 questions in one call and park the task until the operator answers them. |
The operation is enabled by default as soon as the tool is attached to an agent; the operator can still turn it off on the agent’s Tools tab.
It never asks for approval, because there is nothing to approve — the question is the interaction, and the operator’s answer is the tool result. A call flips the task to AWAITING_INPUT (the parallel to PENDING_APPROVAL) and parks the batch on tasks.pending_state; POST /api/v1/tasks/{taskId}/answer submits the answers and flips the task back to QUEUED. See Agent loop / async → Parked work and operator input for the wire shape.
The limits are enforced: 1-4 questions per call, 2-4 options per question, and a header of at most 30 characters. A violation comes back as a tool error rather than a rejected call. The model is told to use the tool only for decisions that block its work — not for clarifying intent, which is what chat is for.
A parked task waits for a human indefinitely. AWAITING_INPUT is a quiescent state: the worker stops driving the task, and the reaper only sweeps tasks stuck in RUNNING, so nothing times a pending batch out. On an agent that runs on a schedule — or one nobody is watching — an ask is a task that never finishes on its own. Turn the operation off for those agents on the Tools tab.
media — MediaTool
The media tool lets an agent search the media archive, look at an image in it, mint public share URLs for individual assets, and organise them in folders. Its scope setting controls which media_assets rows the agent can see:
scope | What the agent sees |
|---|---|
agent | Assets where asset.agent_id = $agentId — only the calling agent’s own media. |
principal | Assets owned by the calling agent’s principal — direct uploads by the principal’s owner user, plus media attached to any agent of the principal. Works for user-principals AND group-principals. |
principal is the default. It was agent until the release that added inspect_image: the common case is the operator pointing the agent at an image in the library, and an operator’s own upload carries no agent_id to match under scope=agent.
A wrong setting must not widen the reach. A scope value nobody can read — a boolean, a number, an array — and a string that is not agent, principal or user both read as agent, the narrowest scope.
An agent keeps the scope it had. An agent whose scope came from the schema default keeps agent; an agent whose scope was set deliberately — at the agent, global, group, principal or shared-group level — keeps that scope; an agent enabled from now on gets principal. Migration 0105 is what holds the old reach in place: it materialises scope: 'agent' into the agent’s own settings row for an agent that had the media tool enabled and for which no layer supplies a scope — the agent’s own row, the shared group, the tool global, the group layer or the principal layer. The group layer counts only while the group cascade is on (SPORA_TOOLS_GROUP_CASCADE_ENABLED, off by default): with the cascade off, a group principal’s scope governs nothing at runtime, so it does not stop the materialisation. It adds rather than rewrites, because a rewrite could not tell a materialised default from an operator’s deliberate choice, and silently overturning the second would be the worse bug. An agent whose global, principal, shared-group or own setting already supplies a scope is left alone: absence is unambiguous, so there is no deliberate choice to shadow. The migration is idempotent, its rollback takes back only the scopes it wrote, and it runs like every other migration: php bin/spora spora:install. Set Library scope to principal on an agent whose scope is agent to give it the wider reach: a global change does not reach an agent that has a scope of its own, because its own agent-level setting overrides the global value. A global change still reaches an agent only when no layer above the global layer sets scope for it: its own agent-level setting, its principal setting or, while SPORA_TOOLS_GROUP_CASCADE_ENABLED is on, its group setting.
The folder operations ignore scope. They work on the principal’s tree, so search_assets lists every asset of the principal filed in that folder, and file_asset can move any of the principal’s assets — under scope=agent as well as under the default scope=principal. The tree belongs to the principal, not to the calling agent.
The deprecated scope=user value (pre-#221) is treated as a silent alias for principal so existing agent_tool_settings rows keep working without a DB migration. New operators see only agent and principal in the dropdown.
Fourteen of the fifteen operations are enabledByDefault: true. The exception is inspect_image, which ships off — it is absent from the tool schema the model is given until an operator enables it for the agent, on the agent’s Tools tab in the Media Library card. Five are requiresApprovalByDefault: true: get_public_url, create_media, create_folder, rename_folder and delete_folder. inspect_image is a read and asks for no approval.
get_public_urlis the only one that produces a URL which keeps resolving outside the operator’s session. Each call mints a 256-bit unguessable token (or reuses an existing one) and writes it tomedia_assets.public_access_token; the served URL has no auth — the token is the only protection. SeePublicMediaControllerfor the no-auth, token-gated serving endpoint. Under the widenedprincipalscope it can mint a share link for any of the principal’s assets rather than only the agent’s own — the operation whose reach changes most. It is still approval-gated on every call, and the token is per-asset.create_mediais the one write with no natural key: ingest dedupes only on(tool_call_id, source_url), which an authored-text call has neither of, so a retry inserts a second row and a loop has no ceiling. The operator sees the call before the row lands.create_folder,rename_folderanddelete_folderchange a structure the operator curates — the tree the library is filed in — and the operator is the one who decides what that tree looks like.
The distinction that decides the gate is worth stating plainly, because it is the reason get_public_url is the odd one out among the reads. data.asset_url on any media operation is the /api/v1/assets/<uuid> route, gated on the requester being the asset’s owner or an admin — a handle for the agent’s own follow-up calls, useless to anyone else. get_public_url returns a different path, /api/v1/public/media/<id>?token=…, resolved by token match with no session at all. An operator approving that call is approving the creation of a durable public link, not a read.
Any operation can still be narrowed per agent from the dashboard, including by putting the approval back on an auto-approved operation. That is the supported way to bound write volume, and it needs no new configuration.
Operations
| Operation | Default enabled | Default approval | Purpose |
|---|---|---|---|
search | yes | auto | Run a media_assets query. Filters out derivative rows so the LLM only sees originals. This is also why a PDF’s markdown is not findable here — search is the agent’s only route to assets it was not handed, and derivative rows are excluded from it. Once a parent id is in hand, list_derivatives is how the agent finds the md render. |
get_media | yes | auto | Fetch one asset by id and render it. Echoes the markdown embed, the asset URL, and (for parent rows) the derivatives[] array; rows that are themselves a derivative also carry parent_id so the LLM can walk back up. For a script-capable asset the operator has permitted, it also carries the embed_descriptor and the line to echo to show the asset live — see A script-capable asset can be shown live. |
get_embed_code | yes | auto | Return just the markdown embed string for an asset (no metadata). Carries the same embed_descriptor as get_media for a script-capable asset the operator has permitted, so the chat renders the same live frame beside the snippet. |
get_source | yes | auto | Read the source of an asset so the LLM can iterate on it (re-typeset a .typ source, re-read an extracted document). Text-shaped mimes (text/*, JSON, XML, YAML, SVG, CSV, x-typst) return the bytes inline, capped at GET_SOURCE_TEXT_MAX (5 MiB). Binary mimes do not return raw bytes — instead the asset’s md derivative is read and returned, truncated to GET_SOURCE_DERIVATIVE_PREVIEW_BYTES (64 KiB) and prefixed with a line naming the source asset and stating the bytes are its markdown derivative, so the LLM can tell which render it is holding. When no md derivative exists, fail with a hint pointing at create_derivative. It stays a pure read: it never mints the derivative, so the re-render remains the LLM’s explicit decision. External assets (storage_mode=external) have no Spora-side payload — fail with a get_media hint. Auto-approved because it reads a row the calling agent already owns under the same scope rules as get_media, so it grants no reach the agent did not already have. |
inspect_image | no | auto | Put an archive image in front of the model. Takes asset_id (one asset per call) and an optional question. The result carries a reference to the image; the bytes are read from storage when the request is built, and the image is rendered as an image content block on the user turn after the tool result — the turn that follows the whole run of results, because a provider accepts a tool result only directly after the assistant turn that asked for it. Needs an LLM that accepts image content blocks — otherwise the call fails with a message the model reads, naming the Allow images setting and the model. Refuses a non-image MIME, image/svg+xml, an asset over the endpoint’s per-image ceiling — that ceiling is checked in the call, so an asset over it never becomes an attachment — and an external asset that has no bytes on hand. The request’s own room is a separate, later gate: an image a request has no room for is dropped from that request, the call still succeeds, and the tool result says the image did not fit and was not sent. See Media assets → inspect_image. |
list_derivatives | yes | auto | Enumerate every derivative of a parent asset in the same wire shape the operator dashboard renders on the VersionsStrip (media_id, format, mime_type, asset_url, label, producer_plugin, producer_operation, created_at). Optional format argument narrows the list to one derivative kind (e.g. only PNG renders). This is the real discovery path for an md derivative: search filters derivative rows out, so this is the only way an agent learns a document has a text render to read. |
create_derivative | yes | auto | Generate a fresh derivative of a parent asset by calling the registered MediaDerivativeProducerInterface that matches the parent MIME and the requested format. Idempotent on (parent_id, format, producer_plugin, producer_operation) — re-renders with the same natural key return the same derivative id. Optional options carries producer-specific knobs (e.g. {"page": 0, "ppi": 144} for typst, {"longEdge": 1024} for image producers). Auto-approved: the derivative comes from a parent the agent already owns, it costs a render rather than granting access, and the row is operator-visible in the dashboard. Idempotency is what makes a blind retry the safe pattern. |
create_media | yes | required | Store LLM-authored text (Markdown, plain text, CSV, JSON, XML, YAML) as a new source asset — the only media write that needs no existing parent. HTML is accepted only when the operator has enabled SPORA_MEDIA_ARCHIVE_ALLOW_ACTIVE_TYPES: a browser parses it as a document that can carry script, so it is gated as a script-capable format rather than sitting on the static text list. Takes content (required, 1 MiB cap), filename (required, sanitised, 255-char cap, extension inferred from mime_type when absent), mime_type (optional hint) and prompt (optional provenance → media_assets.prompt). The declared mime_type is a hint only: the byte ingest path always re-sniffs, and a row landing on a non-allowlisted MIME is deleted and the call rejected, so data.mime_type is the authoritative value. Not idempotent — ingest dedupes only on (tool_call_id, source_url), which an authored-text call has neither of, so a retry creates a second asset; reuse the returned asset_id. Approval-gated by default, and the gate is the point: this is the one write with no natural key, so a looping or prompt-injected agent can insert unbounded permanent rows, capped only per call at the 1 MiB content limit, and nothing in the database stops the duplicate. It is deliberately not isTemporary, because an authored document is a deliverable and auto-deleting it on a retention count would be the worse bug. Operators who have decided they trust their agent with it can drop the approval per agent from the dashboard — that override already exists and needs no new configuration. |
get_public_url | yes | required | Mint (or reuse) an unguessable public-access token. See PublicMediaController. One of the five approval-gated operations: the only one that hands out a link that keeps resolving outside the operator’s session. |
list_folders | yes | auto | The principal’s folders: id, name, path, parent_id, asset_count. Scoped to the principal’s tree rather than to the agent, so scope does not apply to it. |
create_folder | yes | required | Create a folder in the principal’s tree (name, optional parent_id). Sibling names are unique, so a name already taken under the same parent is refused. Approval-gated: it adds a row to a tree the operator curates. |
rename_folder | yes | required | Rename a folder (folder_id + name); the path of the folder and of its subfolders follows. Approval-gated, like the other two folder mutations. |
delete_folder | yes | required | Delete a folder (folder_id); its assets fall back to the root, its subfolders go with it. Approval-gated, like the other two folder mutations. |
file_asset | yes | auto | File an asset into a folder (asset_id + folder_id); omit folder_id to move it back into the root. A folder that already holds a file with that name refuses it. Auto-approved because it moves a row the principal already owns. |
search_assets | yes | auto | The assets inside one folder (folder_id). Scoped to the principal rather than to the agent, so it lists every asset of the principal filed in that folder. |
The derivatives[] enrichment on get_media and the create_derivative op both read through MediaAssetSerializer::derivativeRowsFor() so the operator dashboard and the LLM see the same row shape. See MediaDerivativeController for the underlying REST surface that operators use directly.
A script-capable asset can be shown live
A text/html or image/svg+xml asset the operator has permitted can be shown to the operator as a live widget rather than a download card, and the agent asks for it with a link:
[test-dashboard.html](/api/v1/media/<asset_id>/embed)Two things travel with that:
embed_descriptorin the result’s data channel —{url, mime, scripts}, ornull.create_media,get_mediaandget_embed_codeall carry it, so the chat can mount the frame beside the markdown. The descriptor is the server’s decision, and the client cannot widen it:scriptssays whether the framed document may run script, and the server’sContent-Security-Policyheader is the ceiling the browser enforces.- The line itself, in the result’s text.
create_mediaandget_mediaput the exact markdown link to echo in their result, so the agent copies a link it is handed rather than composing a route — measured on a live install, an agent told to compose one got it wrong, and an agent told in prose wrote the prose.get_embed_codereturns the embed alone, with no line.
The download path (/api/v1/assets/<uuid>.<ext>) stays a plain link, and a get_public_url share link is never framed. See Media assets → Where the frame appears, and where it does not.
Text extraction from a binary document is an md derivative, not a column on the asset. A PDF or docx gets one minted at ingest, and again at attach time for any task that references it, so by the time an agent sees the attachment the md row usually exists. The rule the attachment path follows is: a text-ish source within the 512 KB inline budget is its own text; anything else gets an md derivative, and if it still doesn’t fit, the LLM is told where to read it — the metadata-only fallback block names get_source rather than reporting “no extractable text”. get_source reads the md derivative for binary mimes and does nothing else; create_derivative is how the LLM mints one when it is missing. See Media assets → 6. Derivatives for the MediaDerivativeService contract, the producer’s field-inheritance rules, and why list_derivatives rather than search is the discovery path for an md render.
Admin users bypass scope and see every asset.
principal_info — PrincipalInfoTool
The principal_info tool answers the question an agent asks first: who is this agent talking to? The answer is the principal the agent belongs to — the person who owns it, or the group that owns it. It is deliberately not the person who triggered the run, and for a group-owned agent it is not the group’s first owner either: the answer is the group itself, with its own name, description, information block and saved locations.
| Operation | Default enabled | Default approval | Purpose |
|---|---|---|---|
get_base_data | yes | auto | The principal’s name, description and the fields that go with it. |
get_locations | yes | auto | The principal’s saved locations. |
get_health_data | no | required | The principal’s height and weight — a user principal only. |
get_base_data answers for a user principal:
Principal Type: user
Name: Alice
Description: Hello world
Date of Birth: 1990-05-15and for a group principal:
Principal Type: group
Name: Acme Corp
Description: We build things
Information:
## Address
Musterstraße 1, 10115 BerlinDescription is the principal’s short blurb — a user’s about_me, a group’s description. Information is the group’s rich Markdown block, and it is omitted for a user principal entirely. Date of Birth is a user field; a group has none.
get_locations answers with the principal’s saved locations — the same rows for a person and for a group:
Locations:
— HQ (default)
Address: Musterstraße 1, 10115 BerlinWith nothing saved, the answer is No locations saved.
get_health_data is refused for a group, and it fails rather than answering with an empty field:
Health data is only available for user principals. This agent belongs to a group.Height and weight belong to a body, and a group has none. An empty answer would read to the model as “nothing was recorded”, which is a different claim from “this data does not exist”.
The refusal only reaches an agent that asks for it. The operation is disabled by default and needs operator approval, and an operation that is switched off is filtered out of the schema handed to the model — so a group agent on the default configuration never sees get_health_data and is never told about the refusal. The operation stays in the agent’s tool manifest, which is what read_agent returns and what the Tools tab shows, but that manifest is not the model’s callable schema. Switch the operation on for the agent, approve the call, and the refusal above is what comes back.
When the principal cannot be resolved at all, the call fails with Principal not found.
The tool reports the principal and never the task’s initiator. A group agent can be run by any member, and a member is not the group’s identity — attaching the person who pressed the button would answer a different question than the one the agent is asking, and would put an individual’s details into a shared group’s transcript.