tool_creation

A guide to creating four kinds of tools for InitRunner, including built-in Python tools, custom Python modules, YAML-defined web APIs, and distributable plugins. InitRunner is the system these tools extend.

In plain words
What is it for?
Use it when adding a new tool, exposing a Python function, defining REST endpoints in YAML, or packaging a tool for reuse.
Why use it?
It explains which implementation approach fits a tool and how external tools differ from tools built into InitRunner itself.

Agent

Install

Getting it into your agent

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

agentmods
npx agentmods add agents/vladkesler/initrunner/tool_creation
Clone the repo
git clone --depth 1 https://github.com/vladkesler/initrunner
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 5,673 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

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

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.05673
Opus 5 $0.00000 $0.02837
Sonnet 5 $0.00000 $0.01135
Haiku 4.5 $0.00000 $0.00567

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

Security

Grade A, and why

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

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

Nothing flagged

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

docs/agents/tool_creation.md · 581 lines

How it starts

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

Tool Creation Guide

This guide covers the four ways to extend InitRunner with tools: built-in tools (contributing to InitRunner itself), custom tools (Python modules), declarative API tools (YAML-only), and the plugin registry (distributable packages).

Built-in Tools

Built-in tools ship with InitRunner. Each one lives in a single file and self-registers using the @register_tool decorator. Use this pattern when contributing a new tool to the InitRunner codebase itself. For external/third-party tools, use Custom Tools or the Plugin Registry instead.

Single-file pattern

A built-in tool is one Python file containing a config class, a builder function, and the @register_tool decorator:

# initrunner/agent/tools/redis.py

from typing import Literal
from pydantic_ai.toolsets.function import FunctionToolset
from initrunner.agent.schema.tools import ToolConfigBase
from initrunner.agent.tools._registry import register_tool, ToolBuildContext


class RedisToolConfig(ToolConfigBase):
    type: Literal["redis"] = "redis"
    host: str = "localhost"
    port: int = 6379

    def summary(self) -> str:
        return f"redis: {self.host}:{self.port}"


@register_tool("redis", RedisToolConfig)
def build_redis_toolset(config: RedisToolConfig, ctx: ToolBuildContext) -> FunctionToolset:
    toolset = FunctionToolset()

    @toolset.tool_plain
    def redis_get(key: str) -> str:
        """Get a value from Redis."""
        import redis
        r = redis.Redis(host=config.host, port=config.port)
        return r.get(key) or ""

    return toolset

The tool is immediately available in role YAML as type: redis — no other files need editing.

Tools use PydanticAI's FunctionToolset under the hood. The @toolset.tool_plain decorator registers individual functions (use @toolset.tool only when the function takes a RunContext as its first parameter), and PydanticAI handles parameter schema generation from type annotations and docstrings.

Read the full file on GitHub · 581 lines

Changes

What this file has done since we first saw it

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

  1. 2d ago First seen · 581 lines · 0 tokens per session scan A 305905337a28

Subscribe to this mod's changes

tool_creation is an agent published in the GitHub repository vladkesler/initrunner (41 stars, last pushed 4d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 5,673 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.