算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
tool-design【设计与创意】Design or audit the tools an AI agent calls (MCP server tools, function calling, Runtype runtime and saved tools), or find out why an agent picks the wrong tool or misuses one. Routes naming, schema, output, error, execution, and security work to focused guides.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
A tool that returns correct data can still fail in production because the agent could not tell when to call it, what to pass, or what to do with the result. "Working" is not the same as "agent-usable". This skill family treats the agent as the consumer and designs for it.
The guidance is framework-neutral: it applies to MCP servers, native function calling,
Runtype runtime tools, and any custom loop. It is organized as 54 named patterns across
ten questions; references/pattern-index.md maps every pattern to the skill that owns
it.
| Aspect | Integration middleware | Agent tools |
|---|---|---|
| Consumer | Applications | An LLM |
| Routing | Predetermined flows | Chosen by the agent at runtime |
| Errors | Dead-letter queue | Recovery guidance the agent can act on |
| Documentation | Written for humans | Written for machine comprehension |
| Composition | Orchestrated by a bus | Chained by the agent, non-deterministic |
Nothing enforces sequence for the agent. The tool descriptions, parameter shapes, result shapes, and error messages are the only orchestration layer there is.
query (read-only, retryable, cacheable), command (side effects, document
irreversibility), or discovery (reveals what exists, schema, capabilities).tool-design-interface: a verb-object name, a description
that says when to use it and when not to, constrained parameters, smart defaults,
natural identifiers, and dependency hints.tool-design-output: flat, token-efficient, paginated by
cursor, summary by default, with GUI links and a next-action hint.tool-design-errors: classify every error as
retryable, permanent, needs-user-input, or needs-auth, and attach recovery steps.tool-design-execution: timeout, idempotency
key, transaction or compensation, async job when work exceeds the sync budget.tool-design-security: secrets injected server-side,
permission checks in code, declared scopes, audit log, identity anchor.tool-design-composition: does it bundle a common
sequence, accept a batch, offer preview mode, sit on an abstraction ladder?Run this when asked to audit, review, or "figure out why the agent misuses" a toolkit.
tool-design-interface: free-form strings that
should be enums, required parameters that could default, ids where a natural
identifier would do, secrets accepted as parameters (a security finding, not a
style one), ambiguous "one of X or Y" pairs without enforcement.tool-design-output: raw upstream payloads, nested
blobs, unbounded lists, missing hasMore and cursor, no GUI link, batch results
that collapse to all-or-nothing.tool-design-errors: raw status codes, messages with
no next step, no retryable/permanent distinction, ambiguity resolved by guessing.tool-design-execution and
tool-design-security: command tools with no idempotency story, work that cannot
finish inside the timeout, permission logic in the system prompt, no audit trail.tool-design-composition: near-duplicate tools,
sequences the agent always performs together (bundle candidates), N-item loops
(batch candidates), destructive tools without a preview mode, more tools than the
model can hold in context at once.Start atomic and watch traces. Each signal maps to a specific move:
| Signal in traces | Move |
|---|---|
| High retry rate on one tool | Fix description and error guidance first |
| The same tool sequence repeated across runs | Bundle it into a task tool |
| Per-item loops over the same tool | Add a batch variant |
| Partial completion of multi-step operations | Add a transaction boundary or compensation |
| Agent calls a tool it lacks prerequisites for | Add dependency hints and a discovery tool |
| Agent picks the wrong one of two similar tools | Merge them or sharpen the "use when / not when" |
| Long-running calls time out | Convert to an async job |
Do not build the orchestrated version first. Composite tools built before atomic usage is understood encode guesses about workflows the agent never runs.
Every tool must pass all of these before it reaches an agent:
hasMore.references/checklist.md carries the same list with the pattern each row comes from.
The preceding sections are framework-neutral. When you build natively on Runtype, the platform enforces most of these patterns, so your job is to know which mechanism carries each one.
Tool kind (toolType) | What it is | Patterns it carries |
|---|---|---|
external | HTTP call defined by url, method, headers, body template | Tool Adapter, Secret Injection ({{secret:KEY}}), request mapping (the body template) |
custom | Sandboxed code (JavaScript by default; TypeScript or Python in a sandbox environment) | Parameter Coercion, Response Shaper, Error Classification, Natural Identifier resolution; Tool Adapter when it opts into networkAccess |
flow | A saved flow exposed as one tool, run synchronously | Task Bundle, Tool Chain, Compensation (per-step errorHandling), Response Shaper (outputVariable) |
subagent | Delegation to a saved or inline agent (agentId or agent) | Abstraction Ladder (the orchestrated rung), Scatter-Gather, Async Job (detached mode) |
local | Executed by the client (browser widget or SDK caller) | Confirmation Request, anything needing the user's environment |
mcp | A tool discovered from an MCP server | Tool Gateway, Tool Registry (discover_mcp_server_tools) |
builtin / Orthogonal | Platform catalog tools (attached by id, not created) | Canonical Tool Model, house style for descriptions |
An external tool returns the upstream response as-is; shape it in a flow tool
(api-call step into transform-data) or in a downstream transform-data step. A
custom tool can make the call itself only when it opts in: set networkAccess to an
allowedHostnames list, and declare any managed secret in secrets so the code sends a
phantom token that the egress proxy swaps for the real credential. Without
networkAccess, a custom tool has no network egress. A flow tool returns the flow's terminal step output; set
config.outputVariable to return one shaped variable instead. Long-running work is not
a flow tool either: a subagent tool with config.execution.mode: "detached" returns
a run handle, and run_flow with async: true returns an execution id (see
tool-design-execution).
create_tool also accepts graphql, but no executor runs that type: a call to a
graphql tool fails with an unsupported-type error. Send a GraphQL query from an
external tool with method: "POST" and the query in the body template.
The MCP create_tool accepts tool_type in flow, custom, external, graphql,
mcp, local, with name, description, parameters_schema (JSON Schema), and
config. name is at most 100 characters and description at most 500 on create, so
keep the description tight and put detail in parameter descriptions and error text. The
REST API and SDKs (POST /v1/tools, spelled toolType and parametersSchema) accept
the same set plus subagent. To delegate to agents over MCP, pick the route by need:
execute-agent step and
register that flow with tool_type: "flow". Agent ids are not valid tool ids.config.tools.subagentConfig, which gives it a spawn_subagent tool.builtin tools are never created; attach them by id through config.tools.toolIds.
Iterate with update_tool and get_tool; read
get_platform_documentation(topic="external-tools") and
get_platform_documentation(topic="limits") before designing.
{{secret:KEY}} references resolve server-side and are the only
credential contract. Never collect secret values in chat; hand the user the intake
URL from get_secret_intake_manifest.tools.runtimeTools or
/v1/dispatch), hiddenParameterNames strips parameters from the model-facing schema
and fills them from execution variables. List _endUser or _tenant there to anchor
the verified caller identity so the model never supplies it. Saved tools created with
create_tool do not take this field. Names under _internal are rejected; use
{{secret:KEY}} for credentials.config.elicit on an external or custom tool pauses the run
for a form before approval and dispatch. Use it instead of letting the model invent
an argument that belongs to the person.config.tools.approval.require pauses the run for a human on the
listed tools; the agent's _approvalReason is display-only, never a control signal.
approval.timeout (default 5 min), approval.requestReason, and approval.choices
(alwaysAllow, alwaysDeny) shape the prompt. Approval covers only calls a model
chooses in an agent or prompt step. A flow tool-call step always runs, unattended.idempotent: true only on runtime tools that are safe to run twice,
such as reads or writes keyed by an idempotency key. When a turn is interrupted
mid-call, Runtype re-runs only those; any other call returns an "effects unknown,
verify before retrying" error instead of running twice. For MCP tools, declare
readOnlyHint or idempotentHint on the server; with neither, the tool is treated
as unsafe to re-run.runtype-asset:// handle. Declare a parameter as
{ "type": "string", "contentEncoding": "base64" } to receive those bytes; Runtype
substitutes them before dispatch, so the model never re-emits the payload. This is
the Resource Reference pattern on Runtype.trace_execution.timeout in milliseconds, up to 300 s in the tool editor. MCP tools default to 30 s
and can run up to 300 s only in background runs. A subagent tool defaults to 5 min.
Longer work belongs in an async flow run or a detached subagent.maxToolCalls bounds tool-call loops, and toolCallStrategy is
auto, required, or none. Do not set perToolLimits: it is retired, and an agent
that carries it is rejected. Bound the loop with loopConfig.maxTurns or
loopConfig.maxCost, or enforce a per-tool budget inside the tool. codeModeConfig
gives the agent a code_mode tool that chains a subset of its tools in sandboxed
code, an alternative to hand-built bundle and batch tools.tool_search, and
tools.toolSearch.enabled: false opts out). Single-turn agents send every tool on every
request, so keep sets small or split them across agents.validate_flow reports several checklist rows as stable codes
(see references/checklist.md, "Checked for you on Runtype").validation.warnings and validation.recommendations in the create_tool or
update_tool response. The save succeeds even when they are present, so no error
tells you to look.execute_tool with the inputs an agent will plausibly send, including wrong ones,
and read the result and error as the model would.execute_agent or dispatch.add_eval_case_from_execution, then
run_eval_suite after every description or schema change. Read
get_platform_documentation(topic="evals") for tool-use eval layers.