OpenHarness

repository·main·Indexed 12 days ago

https://github.com/hkuds/openharness

A lightweight infrastructure for building AI agents with capabilities for tool-use, memory, and multi-agent coordination. It includes a Python port of Claude Code and powers 'ohmo', a personal AI assistant capable of autonomous coding tasks such as forking branches, writing code, and opening pull requests. Features include an Agent Loop for tool-call cycles, a toolkit of 43+ tools, Model Context Protocol (MCP) support, and governance layers for permission management.

Tokens
36.6K
Snippets
123
Records
174
Agent score
96%

What's inside OpenHarness

  1. What is OpenHarness and ohmo?

    main

    OpenHarness

    OpenHarness is a lightweight agent infrastructure designed for tool-use, skills, memory, and multi-agent coordination. It provides the 'hands, eyes, memory, and safety boundaries' that wrap around an LLM to turn it into a functional agent.

    ohmo

    ohmo is a personal AI agent built on top of OpenHarness. Unlike a standard chatbot, it is designed for long-running sessions and can perform autonomous tasks such as:

    • Forking branches
    • Writing code
    • Running tests
    • Opening Pull Requests (PRs)

    ohmo uses your existing Claude Code or Codex subscriptions, so no additional API keys are required.

  2. Workflow for the commit skill

    main

    When performing a commit, the skill follows these steps:

    1. Analyze Changes: Run git status and git diff to understand all current changes.
    2. Categorize: Analyze changes to determine if they are a feature, fix, refactor, docs, test, etc.
    3. Draft Message: Create a concise commit message:
      • First line: Use the imperative mood, keep it under 72 characters, and describe the "why".
      • Body: If necessary, explain the context, trade-offs, or breaking changes.
    4. Stage Files: Stage only relevant files. Security Rule: Never stage .env files, credentials, or large binaries.
    5. Execute: Create the commit.
  3. How the 'plan' skill works

    main

    The plan skill is designed to facilitate architectural and design thinking before any code is modified. It is triggered when a user asks to plan, design, or architect a feature. The skill follows a structured workflow to ensure implementation is grounded in the existing codebase and requirements.

    Workflow

    1. Requirement Analysis: Identify the problem, constraints, and expected outcomes.
    2. Codebase Exploration: Search for reusable functions, existing patterns, and target files for modification.
    3. Approach Design: Break the task into discrete steps, identify dependencies, and account for edge cases/error handling.
    4. Plan Presentation: A valid plan must include:
      • A Context section (the 'why').
      • Concrete steps including specific file paths.
      • A Verification section (how to test the implementation).

    Operational Rules

    To ensure high-quality planning, the skill adheres to these constraints:

    • Read before suggesting: Never propose code changes without first reading the relevant files.
    • Prefer reuse: Edit existing files and reuse existing patterns/utilities rather than creating new ones whenever possible.
    • Precision: Always include file paths and line numbers when referencing code.
    • Proportionality: Match the planning complexity to the actual task complexity.
  4. Best practices for writing tests

    main

    When using the test skill, follow these rules to ensure high-quality test suites:

    • Focus on behavior: Test what the code does, not its internal implementation details.
    • Granularity: Aim for one assertion per test when possible.
    • Naming: Use descriptive test names that clearly explain the scenario being tested.
    • Scope: Do not test the underlying framework or library code itself.
    • Isolation: Mock at system boundaries, such as external APIs, the filesystem, or the network, to ensure tests remain fast and deterministic.
  5. Core Agent Harness Features

    main

    OpenHarness provides several key architectural components for agentic workflows:

    • Agent Loop: Supports streaming tool-call cycles, parallel tool execution, API retries with exponential backoff, and token/cost tracking.
    • Harness Toolkit: Includes 43+ tools (File, Shell, Search, Web, MCP) and supports on-demand skill loading via .md files.
    • Context & Memory: Features CLAUDE.md discovery/injection, MEMORY.md for persistent memory, context compression (auto-compact), and session resumption.
    • Governance: Provides multi-level permission modes, path-level and command rules, and interactive approval dialogs via PreToolUse and PostToolUse hooks.
    • Swarm Coordination: Enables subagent spawning, delegation, team registry, and task management.
  6. Use Dry-run for safe previewing

    main

    The --dry-run flag allows you to preview what OpenHarness would do without actually executing models, tools, subagents, or connecting to MCP servers. It is useful for checking configurations and permissions safely.

    Dry-run behavior:

    • Parses: Settings, auth status, system prompts, skills, commands, tools, and MCP configurations.
    • Does NOT: Call models, execute tools, spawn subagents, or connect to MCP servers.
    • Outputs: A readiness conclusion (ready, warning, or blocked) and next actions suggestions.

    Usage Examples:

    • Preview an interactive session: oh --dry-run
    • Preview a specific prompt: oh --dry-run -p "your prompt"
    • Preview a slash command: oh --dry-run -p "/command"
    • Output structured JSON for scripts: oh --dry-run -p "prompt" --output-format json
    oh --dry-run -p "Explain this repository" --output-format json
  7. Understand the Agent Harness Architecture

    main

    OpenHarness is built on the Agent Harness pattern, consisting of several subsystems that manage the lifecycle of an AI agent. The core of the system is the Agent Loop, which follows this logic:

    1. The model receives a prompt and generates a response.
    2. If the response requires a tool (stop_reason == "tool_use"), the harness executes the tool (after permission checks and lifecycle hooks).
    3. The tool result is appended to the message history.
    4. The loop continues until the model provides a final response.

    Key Subsystems:

    • engine: The Agent Loop.
    • tools: 43 tools (file I/O, shell, search, web, MCP).
    • skills: On-demand knowledge via .md files.
    • mcp: Model Context Protocol client.
    • permissions: Safety layers (path rules, command deny).
    • coordinator: Multi-agent coordination and subagent spawning.
  8. Rules for the simplify skill

    main

    When using the simplify skill, the following constraints apply to ensure the refactoring process remains safe and effective:

    • Preserve Behavior: Do not add new features or change the existing behavior of the code; focus exclusively on simplification.
    • Prefer Deletion: It is better to delete code than to refactor it into a more complex structure.
    • Avoid Premature Abstraction: Follow the principle that "three similar lines are better than a premature abstraction."
    • Cleanup: Remove backwards-compatibility shims for features that have been removed.
    • Minimalism: Do not add comments to explain code that has been made simple.
  9. Test provider compatibility

    main

    OpenHarness acts as a harness for various Anthropic-compatible backends. It can be used to compare different providers behind a unified interface, including:

    • Standard Anthropic setups.
    • Moonshot/Kimi via Anthropic-compatible endpoints.
    • Vertex-compatible and Bedrock-compatible gateways.
    • Internal proxies exposing an Anthropic-style API.
  10. Rules for effective code reviews

    main

    When using or configuring the review skill, the following rules ensure high-quality feedback:

    • Be specific: Use exact references like line 42 may throw if user is null instead of vague instructions like check for null.
    • Suggest fixes: Do not just identify problems; provide suggested solutions.
    • Acknowledge good patterns: Highlight positive aspects of the code alongside critiques.
    • Avoid formatting nitpicks: If a linter is present in the project, do not use the review skill to point out formatting issues.
  11. Configure models and providers with `oh setup`

    main

    The recommended way to configure your AI backends is using the oh setup command. This command provides a guided workflow to set up your environment.

    The oh setup workflow follows these steps:

    1. Select a workflow (e.g., OpenAI-Compatible, Anthropic-Compatible).
    2. Complete authentication if required.
    3. Select a specific backend preset.
    4. Confirm the model.
    5. Save and activate the profile.

    Supported Workflows

    • Anthropic-Compatible API: For Claude official API, Moonshot/Kimi, Zhipu/GLM, MiniMax, etc.
    • OpenAI-Compatible API: For OpenAI, OpenRouter, DeepSeek, Ollama, Groq, etc.
    • Claude Subscription: Uses local ~/.claude/.credentials.json.
    • Codex Subscription: Uses local ~/.codex/auth.json.
    • GitHub Copilot: Uses GitHub Copilot OAuth workflow.
    oh setup