Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Migrating the Config API

The 3.0 release made agent-client-protocol-http::ServerOptions, agent-client-protocol-http::CorsOptions, and agent-client-protocol::AcpAgentConfig non-exhaustive so future configuration fields or policies can be added without another breaking release.

HTTP server options

Breaking: downstream crates cannot construct ServerOptions with a struct literal, including ..ServerOptions::default() update syntax.

Before (no longer compiles outside the HTTP crate):

let options = ServerOptions {
    path: "/agent".into(),
    cors: CorsOptions::allow_origins(["https://example.com"])?,
    health_endpoint: false,
};
// Partial literals with ..ServerOptions::default() also need migration.

After:

#![allow(unused)]
fn main() {
use agent_client_protocol_http::{CorsOptions, ServerOptions};

let options = ServerOptions::default()
    .with_path("/agent")
    .with_cors(CorsOptions::allow_origins(["https://example.com"])?)
    .with_health_endpoint(false);
}

All existing fields remain public, so reading or assigning options.path, options.cors, or options.health_endpoint still works. Destructuring patterns must include ...

Defaults and runtime policies are unchanged: /acp, disabled cross-origin browser access, and an enabled /health endpoint. Setters replace the chosen value and preserve the other options.

CORS policies

In 3.x, CorsOptions was a #[non_exhaustive] enum, so exhaustive matches outside the HTTP crate needed a wildcard arm.

Breaking: in v5, CorsOptions is an opaque struct and its variants are no longer public. Code that matched on the variants no longer compiles. Build policies with CorsOptions::disabled(), CorsOptions::allow_origins(...), or CorsOptions::allow_any_origin(), and compare them with ==:

#![allow(unused)]
fn main() {
use agent_client_protocol_http::CorsOptions;

fn is_disabled(policy: &CorsOptions) -> bool {
    *policy == CorsOptions::disabled()
}
}

CORS does not authenticate requests. Authorization headers and credentialed CORS are host-owned policies; see browser authentication and credential policy.

Agent subprocess configuration

AcpAgentConfig already has private fields. Keep using its existing constructor and fluent methods; no new builder type or Default is required because an executable must be specified:

#![allow(unused)]
fn main() {
use agent_client_protocol::AcpAgentConfig;

let config = AcpAgentConfig::new("python")
    .arg("agent.py")
    .args(["--mode", "fast"])
    .env("RUST_LOG", "info")
    .envs([("NO_COLOR", "1")]);
}

Its getters, serialization, required command, empty argument/environment defaults, and rejection of unknown JSON fields are unchanged.