Configuration & Extensibility¶
microharness uses cascading configuration across two scopes:
- Global User Baseline:
~/.microharness/(or--global-dir) - 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:
models.<alias>.max_context_tokens- Provider profile
context_tokens - Live
/modelsmetadata probe (when supported by the provider) - Global
max_context_tokens/max_tokens/context_tokens(default262144incore/defaults.json)
Switching models dynamically with /model applies the new model's context cap immediately.
Streaming, Vision & Provider Capabilities¶
"stream"(defaulttrueincore/defaults.json; toggle via--stream/--no-streamorHarness(..., 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"(bothtrueby default) to disable SSE streaming orstream_options: {"include_usage": true}for incompatible endpoints;HttpChatModelalso auto-falls back and latches on rejection. "supports_vision"(defaultfalseincore/defaults.json; set per provider incore/providers.jsonand overridable permodels.<alias>or top-levelconfig.json) controls whether multimodalimage_urlblocks 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"(default5242880),"image_token_estimate"(default1024), and"allowed_image_mime_types"(["image/png", "image/jpeg", "image/gif", "image/webp"]) are declared incore/defaults.json.
Configuration Precedence¶
From highest priority to lowest:
- CLI Flags /
Harness(...)kwargs (--model,--endpoint,--api-key,--preset,--sandbox,-d) - Environment Variables / Local
.env(MODEL_ENDPOINT,MODEL_NAME,MODEL_API_KEY, provider env keys) - Global Credential Store (
~/.microharness/auth.json) - Project Config (
.microharness/config.json, skipped when an active preset setsisolated: trueorinherit_project: false) - Agent Preset (
~/.microharness/presets/<name>/or.microharness/presets/<name>/) - Global Config (
~/.microharness/config.json) - 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.mdor./AGENTS.mdin 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.mdviaread_filewhen 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.pyin interactive chat or passmicroharness "/review src/auth.py". - Argument Substitution:
$ARGUMENTSor{args}expands to your trailing arguments. - Discovery:
/helplists 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": truein~/.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)]
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>"}.