Skip to content

Configuration & Extensibility

microharness uses cascading configuration across two scopes:

  1. Global User Baseline: ~/.microharness/ (or --global-dir)
  2. Project-Local Scope: .microharness/ in your repository root

Project-level definitions shadow global definitions with the same identifier, while security-sensitive features (project Python tool plugins, project MCP servers, and project command hooks) remain isolated behind an explicit trust boundary.


1. Configuration Files (config.json)

Both ~/.microharness/config.json and .microharness/config.json support JSONC (// and # comments).

{
  "default_model": "smart",
  "max_context_tokens": 64000,
  "trigger_ratio": 0.80,
  "max_tool_tokens": 8000,
  "stream": true,
  "sandbox": false,
  "models": {
    "fast": {
      "model": "gemini-2.5-flash",
      "provider": "google-ai-studio",
      "description": "Fast flash model"
    },
    "smart": {
      "model": "anthropic/claude-5.5-sonnet",
      "provider": "openrouter",
      "max_context_tokens": 200000,
      "description": "Frontier reasoning model"
    },
    "local": {
      "model": "local-model",
      "provider": "lmstudio",
      "endpoint": "http://localhost:1234/v1",
      "description": "Local offline LLM"
    }
  }
}

Per-Model Context Caps

A models entry can specify max_context_tokens, and a provider profile in providers.json can declare context_tokens. Effective context window resolution follows:

  1. models.<alias>.max_context_tokens
  2. Provider profile context_tokens
  3. Live /models metadata probe (when supported by the provider)
  4. Global max_context_tokens / max_tokens / context_tokens (default 262144 in core/defaults.json)

Switching models dynamically with /model applies the new model's context cap immediately.

Streaming, Vision & Provider Capabilities

  • "stream" (default true in core/defaults.json; toggle via --stream / --no-stream or Harness(..., stream=...)) controls live Server-Sent Events (SSE) token, reasoning, and tool-call streaming.
  • Provider profiles in core/providers.json (or ~/.microharness/providers.json) accept "supports_streaming" and "supports_stream_usage" (both true by default) to disable SSE streaming or stream_options: {"include_usage": true} for incompatible endpoints; HttpChatModel also auto-falls back and latches on rejection.
  • "supports_vision" (default false in core/defaults.json; set per provider in core/providers.json and overridable per models.<alias> or top-level config.json) controls whether multimodal image_url blocks are sent directly to the model or degraded into concise text placeholders ([image: image/png, N KB]) to prevent HTTP 400 rejections on text-only models.
  • "max_image_bytes" (default 5242880), "image_token_estimate" (default 1024), and "allowed_image_mime_types" (["image/png", "image/jpeg", "image/gif", "image/webp"]) are declared in core/defaults.json.

Configuration Precedence

From highest priority to lowest:

  1. CLI Flags / Harness(...) kwargs (--model, --endpoint, --api-key, --preset, --sandbox, -d)
  2. Environment Variables / Local .env (MODEL_ENDPOINT, MODEL_NAME, MODEL_API_KEY, provider env keys)
  3. Global Credential Store (~/.microharness/auth.json)
  4. Project Config (.microharness/config.json, skipped when an active preset sets isolated: true or inherit_project: false)
  5. Agent Preset (~/.microharness/presets/<name>/ or .microharness/presets/<name>/)
  6. Global Config (~/.microharness/config.json)
  7. Declarative Built-in Defaults (core/defaults.json, core/providers.json, MockModel)

Trust boundary for trust_project_tools

Project .microharness/config.json cannot enable "trust_project_tools": true on its own. Project tools, project mcp_servers, and project command hooks are only trusted via --trust-project-tools or "trust_project_tools": true in ~/.microharness/config.json.


2. Cascading Instructions (AGENTS.md)

Provide personal preferences globally and repository rules locally:

  • Global Baseline: ~/.microharness/AGENTS.md
  • Project Conventions: .microharness/AGENTS.md or ./AGENTS.md in the repository root

The harness loads both in cascading order (Global baseline first, Project local second) into the system prompt.


3. Progressive Skills (.microharness/skills/)

Define reusable agent workflows in ~/.microharness/skills/<name>/SKILL.md ([global]) or .microharness/skills/<name>/SKILL.md ([project]):

  • Skill Shadowing: Project skills with the same name cleanly override global skills.
  • Progressive Disclosure: Only a one-line index with scope badges is injected into the system prompt, preserving context tokens.
  • On-Demand Reading: The agent reads the full SKILL.md via read_file when relevant, or the user can activate a skill with /skill <name>. Global skills are readable without breaking write sandboxing to the project workspace.

4. Custom Slash Commands (.microharness/commands/*.md)

Define reusable user-facing prompt templates in ~/.microharness/commands/<name>.md or .microharness/commands/<name>.md:

# Review code changes
Review the git diff or specified files: $ARGUMENTS.
Check for:
1. Correctness and edge-case logic bugs
2. Unit test coverage
3. Adherence to conventions in AGENTS.md
  • Invocation: Type /review src/auth.py in interactive chat or pass microharness "/review src/auth.py".
  • Argument Substitution: $ARGUMENTS or {args} expands to your trailing arguments.
  • Discovery: /help lists discovered commands with their [project] or [global] badges. Project commands shadow global ones.

5. Custom Tool Plugins (.microharness/tools/*.py)

Extend the agent with Python tools without modifying core/:

  • Global Tools (~/.microharness/tools/*.py): Trusted and loaded automatically across all projects.
  • Project Tools (.microharness/tools/*.py): Require --trust-project-tools (or "trust_project_tools": true in ~/.microharness/config.json).
  • Shadowing: Project tools override global tools with the same name. Overriding a built-in tool emits a warning for visibility.

Authoring Patterns

class CalculatorTool:
    name = "calculate"
    description = "Evaluates basic math expressions safely"
    parameters = {
        "type": "object",
        "properties": {
            "expression": {
                "type": "string",
                "description": "The math expression (e.g. '24 * 7')",
            }
        },
        "required": ["expression"],
    }

    def execute(self, expression: str) -> tuple[int, str]:
        try:
            return 0, str(eval(expression, {"__builtins__": {}}, {}))
        except Exception as exc:
            return 1, f"Error: {exc}"
class DatabaseTool:
    name = "query_db"
    description = "Queries a project SQLite database"
    parameters = {
        "type": "object",
        "properties": {"query": {"type": "string"}},
        "required": ["query"],
    }

    def __init__(self, env=None):
        self.workspace = env.workspace_dir if env else "."

    def execute(self, query: str) -> tuple[int, str]:
        return 0, f"Queried {self.workspace}: {query}"


def get_tools(env=None):
    return [DatabaseTool(env)]
tools = [ToolOne(), ToolTwo()]

6. Plugin Bundles (~/.microharness/plugins/)

For full multi-component extensions (provider.py, tools/, skills/, subagents/, commands/, hooks, mcp_servers, cli, and isolated uv/stdio runtimes), use the Plugin System (microharness plugin install <git-url|path>). Enable/disable state is stored in plugins.json (and configurable via "plugins" / "disabled_plugins" in config.json).


7. Pluggable Request Auth Schemes (~/.microharness/auth/)

Built-in request-signing schemes in core/auth.py are none, bearer, header, and sigv4. Additional single-file RequestSigner plugins can be placed in ~/.microharness/auth/<scheme>.py (global directory only, never project-local) and referenced from providers.json under "auth": {"scheme": "<scheme>"}.