# Agent Adapter Implementations in no-mistakes: A Complete Guide to LLM and Command Providers

> Explore seven agent adapter implementations in no-mistakes: Opencode, Codex, Claude, Copilot, Native Command, Fallback, and Environment. Learn their use cases for LLM and command providers.

- Repository: [Kun Chen/no-mistakes](https://github.com/kunchenguid/no-mistakes)
- Tags: deep-dive
- Published: 2026-07-16

---

**The no-mistakes CLI uses seven distinct agent adapter implementations—Opencode, Codex, Claude, Copilot, Native Command, Fallback, and Environment utilities—to mediate between the pipeline core and external LLM providers or local tools.**

The **no-mistakes** repository implements a plugin-style agent layer that standardizes how the pipeline interacts with large language models and local executables. Each agent adapter implementation shares a common interface defined in [`internal/agent/agent.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/agent.go) but provides specialized transport protocols, authentication mechanisms, and execution models tailored to specific providers. This architecture enables teams to swap between cloud-based LLMs, self-hosted inference endpoints, and deterministic local tools without modifying pipeline logic.

## Core Agent Interface

All agent adapter implementations conform to the `Agent` interface defined in [`internal/agent/agent.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/agent.go). This contract standardizes fields such as `SessionID`, `Model`, and `Provider`, along with optional capabilities including **session resume**, **instrumentation**, and **gate neutralization**.

The pipeline probes these capabilities at runtime. Only adapters implementing the `SupportsSessionResume` interface receive persisted session identifiers for incremental "resume" calls, while [`internal/agent/invocationmetrics.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/invocationmetrics.go) extracts token counts and latency metrics from every invocation regardless of the underlying provider.

## Agent Adapter Implementations and Their Use Cases

The repository ships with concrete adapters optimized for different deployment scenarios, privacy requirements, and execution models.

### Opencode Adapter (Self-Hosted LLM Gateway)

The **Opencode** adapter, implemented across [`internal/agent/opencode.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/opencode.go), [`internal/agent/opencode_http.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/opencode_http.go), and [`internal/agent/opencode_stream.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/opencode_stream.go), provides a generic gateway for self-hosted LLM endpoints. It transmits JSON payloads over HTTP or WebSocket streams and parses structured responses from OpenAI-compatible servers.

Use this adapter when operating private-cloud inference endpoints where data privacy and latency control take precedence over vendor-managed solutions. Organizations running their own model-serving stacks use this implementation to keep sensitive code within their network perimeter.

### Codex Adapter (OpenAI Integration)

Located in [`internal/agent/codex.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/codex.go), the **Codex** adapter integrates directly with OpenAI's Codex model by spawning the `codex exec` CLI subprocess. It parses the JSON event stream to extract completions and token-usage metrics.

This implementation suits developers requiring high-quality, code-centric completions who already maintain OpenAI API credentials. The adapter handles the specific streaming protocol and rate-limiting behaviors unique to the Codex command-line interface.

### Claude Adapter (Anthropic Integration)

The **Claude** adapter in [`internal/agent/claude.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/claude.go) wraps Anthropic's Claude API, managing the required HTTP headers and response formatting specific to Anthropic's "instruction-following" model architecture.

Choose this implementation when projects require Anthropic's safety guarantees or prefer Claude's conversational reasoning style for higher-level architectural tasks rather than pure code completion.

### Copilot Adapter (GitHub Integration)

Implemented in [`internal/agent/copilot.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/copilot.go), the **Copilot** adapter connects to GitHub's Copilot service via the `gh copilot` CLI. It optimizes for low-latency "suggestion" calls and manages the Copilot token-refresh flow automatically.

This adapter fits environments already authenticated with GitHub where teams want completions tightly integrated with repository context and existing GitHub authentication infrastructure.

### Native Command Adapter (Local Tool Execution)

The **Native Command** adapter in [`internal/agent/native_command.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/native_command.go) executes local binaries or scripts—such as `gofmt`, `golint`, or custom linters—and captures their output as structured `AgentResult` objects.

Use this implementation for deterministic tooling where LLM inference is unnecessary or undesirable. It treats local commands as first-class agents within the pipeline, enabling static analysis, formatting, or any machine-readable command output to participate in the same workflow as AI-generated responses.

### Fallback Adapter (Resilience and Reliability)

Defined in [`internal/agent/fallback.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/fallback.go), the **Fallback** adapter implements a chain-of-responsibility pattern that retries candidate adapters in order of preference until one succeeds. It reads the `config.Agent.FallbackOrder` configuration to determine the retry sequence.

This implementation guarantees pipeline continuity when primary providers experience outages or rate limiting. It is essential for production environments requiring high availability across multiple LLM vendors.

### Environment and Server Utilities

While not full adapters, [`internal/agent/env.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/env.go) supplies per-run environment variables such as `OPENAI_API_KEY` and `COPILOT_TOKEN` to underlying implementations. The **Server** utilities in [`internal/agent/server.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/server.go) and [`internal/agent/serverpid.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/serverpid.go) manage long-running subprocess lifecycles, enforce graceful termination, and preserve singleton lock semantics for adapters spawning external processes.

## How the Agent Factory Selects Adapters

The `internal/agent.NewAgent` factory function instantiates the appropriate adapter based on the `config.Agent.Provider` setting and fallback chain configuration. The factory uses a type switch to return concrete implementations:

```go
// Create an adapter based on the configured provider.
// The fallback order is defined in config.Agent.FallbackOrder.
func NewAgent(opts AgentOpts) (Agent, error) {
    var a Agent
    switch opts.Provider {
    case "opencode":
        a = NewOpencodeAdapter(opts)          // HTTP/stream implementation
    case "codex":
        a = NewCodexAdapter(opts)              // OpenAI codex CLI wrapper
    case "claude":
        a = NewClaudeAdapter(opts)             // Anthropic HTTP wrapper
    case "copilot":
        a = NewCopilotAdapter(opts)            // GitHub Copilot CLI
    case "native":
        a = NewNativeCommandAdapter(opts)      // Executes a local binary
    default:
        a = NewFallbackAdapter(opts)           // Tries providers in order
    }
    return a, nil
}

```

Pipeline steps invoke the adapter through the unified `Execute` method. For example, a review step using the Opencode adapter:

```go
// Example of invoking the Opencode adapter from a pipeline step.
func (s *ReviewStep) invokeAgent(ctx context.Context, prompt string) (*AgentResult, error) {
    agent, err := agent.NewAgent(agent.AgentOpts{
        Provider:   "opencode",
        Model:      "gpt‑4‑turbo",
        SessionID:  s.run.SessionID,
        Env:        s.env,
    })
    if err != nil { return nil, err }

    // The adapter internally decides between HTTP vs stream based on config.
    return agent.Execute(ctx, prompt)
}

```

For local tooling, the Native Command adapter accepts binary paths and arguments:

```go
// Native command adapter – used for a lint step.
func (l *LintStep) runLinter(ctx context.Context, src string) (*AgentResult, error) {
    agent, _ := agent.NewAgent(agent.AgentOpts{
        Provider: "native",
        Cmd:      "golint",
        Args:     []string{"-set_exit_status"},
    })
    return agent.Execute(ctx, src) // returns stdout / stderr as result
}

```

## Summary

- **Opencode**: Self-hosted HTTP/streaming adapter for private-cloud deployments requiring full data sovereignty.
- **Codex**: OpenAI CLI wrapper optimized for code-centric completions and token-usage tracking.
- **Claude**: Anthropic API wrapper for safety-oriented conversational reasoning tasks.
- **Copilot**: GitHub CLI integration for low-latency suggestions within authenticated GitHub environments.
- **Native Command**: Local binary execution adapter for deterministic linting, formatting, and custom tooling.
- **Fallback**: Resilience layer that chains multiple adapters according to `config.Agent.FallbackOrder`.
- **Environment/Server**: Supporting utilities for credential injection and subprocess lifecycle management.

## Frequently Asked Questions

### How do I configure which agent adapter implementation to use?

Set the `Provider` field in your configuration file or environment variables. The `internal/agent.NewAgent` factory reads `config.Agent.Provider` and instantiates the corresponding concrete adapter. For redundancy, populate `config.Agent.FallbackOrder` to enable the Fallback adapter to cycle through multiple implementations when primary providers fail.

### What is the difference between the Opencode and Codex adapter implementations?

The **Opencode** adapter communicates via HTTP requests to self-hosted endpoints, making it provider-agnostic and suitable for on-premise deployments. The **Codex** adapter specifically shells out to the `codex exec` CLI, handling OpenAI's proprietary streaming format and authentication. Use Opencode for generic OpenAI-compatible servers; use Codex specifically for OpenAI's managed Codex service.

### Can I use multiple agent adapter implementations in a single pipeline run?

Yes. Configure the **Fallback** adapter in [`internal/agent/fallback.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/fallback.go) as your primary provider, then define the retry sequence in `config.Agent.FallbackOrder`. The Fallback adapter attempts each implementation in sequence until one returns a successful `AgentResult`, enabling seamless failover between cloud providers and local tools within the same execution context.

### How does the Native Command adapter differ from LLM-based adapters?

While LLM-based adapters like Claude or Copilot generate responses through probabilistic inference, the **Native Command** adapter in [`internal/agent/native_command.go`](https://github.com/kunchenguid/no-mistakes/blob/main/internal/agent/native_command.go) executes deterministic local binaries. It captures stdout and stderr as the response payload, allowing traditional static analysis tools to participate in the agent workflow without requiring neural network inference.