> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openagents.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DSPy and the Compiler Layer

> How dsrs turns agent behavior into typed, optimizable programs.

## Overview

OpenAgents uses a Rust DSPy implementation called **dsrs** as the compiler layer
for agent behavior. Instead of hardcoding prompts, Autopilot expresses behavior
as typed Signatures and Modules that can be evaluated and optimized over time.

## Why DSPy (dsrs) Exists

* Turns prompts into **typed contracts** with strict parsing
* Makes decision logic **auditable and replayable**
* Enables **optimization loops** using real outcome data
* Separates policy (what to do) from execution (how to do it)

## Core Primitives

* **Signatures**: typed input/output contracts for model calls
* **Modules**: composable workflows built from signatures
* **Tools**: structured world interactions with receipts and schemas
* **Adapters**: provider-specific formatting and parsing
* **Optimizers**: MIPROv2, COPRO, GEPA and Pareto search
* **Metrics**: utility and verification-driven scoring

## Where It Lives

* DSPy runtime: `crates/dsrs/`
* Adjutant pipelines: `crates/adjutant/src/dspy/`
* Signature registry: `crates/dsrs/src/signature_registry.rs`

## How It Appears in Autopilot

* Plan Mode signatures drive structured planning.
* Guidance Modules use DSPy decisions between turns.
* Signature-driven UI renders each step in the Autopilot UI.

## Learn More

* See [Signatures and Registry](signatures) for how contracts are defined.
* See [Optimizers and Manifests](optimizers) for how policies improve over time.
