How havish-coder/agent-harness works
Agent Harness is a terminal coding agent: a user submits a task, the session assembles workspace context and a provider-backed agent, the agent requests tools to inspect or change files and run commands, and the terminal streams results while requesting approval for changes. The map also includes provider selection/retries, settings and cost tracking, and the principal tool and UI layers. Relationships come from the excerpts, SOURCE INDEX references, or README; unsampled internals are not assumed to call one another.
Main entry points: session.py Session · cli.py CLI Entry · workspace.py Workspace State · base.py Provider Interface
Components 26
Application
- CLI Entry
harness/cli.py - Settings
harness/config.py - Slash Commands
harness/commands.py - File Mentions
harness/mentions.py - Session
harness/session.py
Agent Runtime
- Agent Loop
harness/agent.py - Message Model
harness/messages.py - Usage Tracking
harness/usage.py
Model Providers
- Provider Factory
harness/providers/factory.py - Retry and Fallback
harness/providers/retry.py - Provider Interface
harness/providers/base.py - Ollama Adapter
harness/providers/ollama.py - Anthropic Adapter
harness/providers/anthropic.py - OpenAI-Compatible Adapter
harness/providers/openai_compat.py
Workspace Tools
- Workspace State
harness/workspace.py - Tool Schema and Safety
harness/tools/base.py - Tool Registry
harness/tools/registry.py - File Listing and Reading
harness/tools/fs.py - Glob and Grep
harness/tools/search.py - File Editing
harness/tools/edit.py - Shell Commands
harness/tools/shell.py
Terminal Interface
- Terminal UI
harness/tui/plain.py - Rich Terminal UI
harness/tui/rich_ui.py - Prompt Input
harness/tui/prompt.py
Other components
- User
- Model Services
Connections 43
- User → CLI Entry: submits task
- CLI Entry → Settings: loads settings
harness/cli.py - CLI Entry → Workspace State: opens workspace
harness/cli.py - CLI Entry → Session: creates session
harness/cli.py - CLI Entry → Slash Commands: dispatches commands
harness/cli.py - CLI Entry → Terminal UI: selects interface
harness/cli.py - CLI Entry → Prompt Input: reads prompts
harness/cli.py - Slash Commands → Settings: updates settings
harness/commands.py - File Mentions → Workspace State: resolves paths
harness/mentions.py - File Mentions → File Listing and Reading: uses file tools
harness/mentions.py - Session → Provider Factory: creates provider
harness/session.py - Session → Retry and Fallback: wraps provider
harness/session.py - Session → Agent Loop: configures agent
harness/session.py - Session → File Listing and Reading: builds workspace snapshot
harness/session.py - Session → Workspace State: tracks workspace
harness/session.py - Session → Usage Tracking: tracks costs
harness/session.py - Session → Terminal UI: forwards events
harness/session.py - Agent Loop → Provider Interface: requests replies
harness/agent.py - Agent Loop → Tool Registry: dispatches tool calls
harness/agent.py - Agent Loop → Message Model: maintains conversation
harness/agent.py - Agent Loop → Terminal UI: emits events
- Provider Factory → Ollama Adapter: selects adapter
harness/providers/factory.py - Provider Factory → Anthropic Adapter: selects adapter
harness/providers/factory.py - Provider Factory → OpenAI-Compatible Adapter: selects adapter
harness/providers/factory.py - Ollama Adapter → Provider Interface: implements interface
harness/providers/ollama.py - Anthropic Adapter → Provider Interface: implements interface
harness/providers/anthropic.py - OpenAI-Compatible Adapter → Provider Interface: implements interface
harness/providers/openai_compat.py - Provider Interface → Message Model: uses message types
harness/providers/base.py - Ollama Adapter → Model Services: calls model API
harness/providers/ollama.py - Anthropic Adapter → Model Services: calls model API
harness/providers/anthropic.py - OpenAI-Compatible Adapter → Model Services: calls model API
harness/providers/openai_compat.py - Retry and Fallback → Provider Interface: wraps provider
harness/providers/retry.py - Tool Registry → Tool Schema and Safety: registers tools
harness/tools/registry.py - File Listing and Reading → Tool Schema and Safety: defines tools
harness/tools/fs.py - File Listing and Reading → Workspace State: reads and tracks files
harness/tools/fs.py - Glob and Grep → Tool Schema and Safety: defines tools
harness/tools/search.py - Glob and Grep → Workspace State: searches workspace
harness/tools/search.py - File Editing → Tool Schema and Safety: defines tools
harness/tools/edit.py - File Editing → Workspace State: checks read state
harness/tools/edit.py - Shell Commands → Tool Schema and Safety: defines tools
harness/tools/shell.py - Shell Commands → Workspace State: uses workspace
harness/tools/shell.py - Rich Terminal UI → Terminal UI: extends rendering
harness/tui/rich_ui.py - Terminal UI → User: shows responses