Module: AgentHarness

Defined in:
lib/agent_harness.rb,
lib/agent_harness/errors.rb,
lib/agent_harness/version.rb,
lib/agent_harness/response.rb,
lib/agent_harness/configuration.rb,
lib/agent_harness/token_tracker.rb,
lib/agent_harness/error_taxonomy.rb,
lib/agent_harness/providers/base.rb,
lib/agent_harness/providers/aider.rb,
lib/agent_harness/providers/codex.rb,
lib/agent_harness/command_executor.rb,
lib/agent_harness/providers/cursor.rb,
lib/agent_harness/providers/gemini.rb,
lib/agent_harness/providers/adapter.rb,
lib/agent_harness/providers/kilocode.rb,
lib/agent_harness/providers/opencode.rb,
lib/agent_harness/providers/registry.rb,
lib/agent_harness/providers/anthropic.rb,
lib/agent_harness/orchestration/metrics.rb,
lib/agent_harness/orchestration/conductor.rb,
lib/agent_harness/providers/github_copilot.rb,
lib/agent_harness/orchestration/rate_limiter.rb,
lib/agent_harness/orchestration/health_monitor.rb,
lib/agent_harness/orchestration/circuit_breaker.rb,
lib/agent_harness/orchestration/provider_manager.rb

Overview

AgentHarness provides a unified interface for CLI-based AI coding agents.

It offers:

  • Unified interface for multiple AI coding agents (Claude Code, Cursor, Gemini CLI, etc.)

  • Full orchestration layer with provider switching, circuit breakers, and health monitoring

  • Flexible configuration via YAML, Ruby DSL, or environment variables

  • Dynamic provider registration for custom provider support

  • Token usage tracking for cost and limit calculations

Examples:

Basic usage

AgentHarness.send_message("Write a hello world function", provider: :claude)

With configuration

AgentHarness.configure do |config|
  config.logger = Logger.new(STDOUT)
  config.default_provider = :cursor
end

Direct provider access

provider = AgentHarness.provider(:claude)
provider.send_message(prompt: "Hello")

Defined Under Namespace

Modules: ErrorTaxonomy, Orchestration, Providers Classes: AuthenticationError, CallbackRegistry, CircuitBreakerConfig, CircuitOpenError, CommandExecutionError, CommandExecutor, Configuration, ConfigurationError, Error, HealthCheckConfig, NoProvidersAvailableError, OrchestrationConfig, ProviderConfig, ProviderError, ProviderNotFoundError, ProviderUnavailableError, RateLimitConfig, RateLimitError, Response, RetryConfig, TimeoutError, TokenTracker

Constant Summary collapse

VERSION =
"0.2.2"

Class Method Summary collapse

Class Method Details

.conductorOrchestration::Conductor

Returns the global conductor for orchestrated requests

Returns:



66
67
68
# File 'lib/agent_harness.rb', line 66

def conductor
  @conductor ||= Orchestration::Conductor.new(config: configuration)
end

.configurationConfiguration

Returns the global configuration instance

Returns:



33
34
35
# File 'lib/agent_harness.rb', line 33

def configuration
  @configuration ||= Configuration.new
end

.configure {|Configuration| ... } ⇒ void

This method returns an undefined value.

Configure AgentHarness with a block

Yields:



40
41
42
# File 'lib/agent_harness.rb', line 40

def configure
  yield(configuration) if block_given?
end

.loggerLogger?

Returns the global logger

Returns:

  • (Logger, nil)

    the configured logger



54
55
56
# File 'lib/agent_harness.rb', line 54

def logger
  configuration.logger
end

.provider(name) ⇒ Providers::Base

Get a provider instance

Parameters:

  • name (Symbol)

    the provider name

Returns:



82
83
84
# File 'lib/agent_harness.rb', line 82

def provider(name)
  conductor.provider_manager.get_provider(name)
end

.reset!void

This method returns an undefined value.

Reset configuration to defaults (useful for testing)



46
47
48
49
50
# File 'lib/agent_harness.rb', line 46

def reset!
  @configuration = nil
  @conductor = nil
  @token_tracker = nil
end

.send_message(prompt, provider: nil, **options) ⇒ Response

Send a message using the orchestration layer

Parameters:

  • prompt (String)

    the prompt to send

  • provider (Symbol, nil) (defaults to: nil)

    optional provider override

  • options (Hash)

    additional options

Returns:

  • (Response)

    the response from the provider



75
76
77
# File 'lib/agent_harness.rb', line 75

def send_message(prompt, provider: nil, **options)
  conductor.send_message(prompt, provider: provider, **options)
end

.token_trackerTokenTracker

Returns the global token tracker

Returns:



60
61
62
# File 'lib/agent_harness.rb', line 60

def token_tracker
  @token_tracker ||= TokenTracker.new
end