github coder/acp-go-sdk v0.10.8
v0.10.8: Schema 0.10.8, extension methods, and cancellation

latest releases: v0.13.5, v0.13.4, v0.13.0...
3 months ago

Catches the SDK up to ACP schema 0.10.8 (from 0.6.3), adds first-class ACP extension methods, full $/cancel_request cancellation, and an opt-in unstable surface for in-development RPCs. A trio of fixes around notification ordering and request/handler synchronization makes streaming sessions behave correctly under load.

Highlights

  • ACP schema 0.10.8 with regenerated types — including typed unstable session selector and capability metadata for clients.
  • New extensibility surface: ExtensionMethodHandler plus CallExtension / NotifyExtension, and Unstable* types for in-development methods.
  • Protocol-level cancellation via $/cancel_request, with per-request contexts and a -32800 error mapping.
  • Notification handling overhauled: in-order delivery, no early returns from Prompt(), and no nested-request deadlocks.

Added

  • Extension methods (#11 by @ThomasK33). Implement the new optional interface to receive any _-prefixed JSON-RPC method, and use the helper methods to send them:

    type ExtensionMethodHandler interface {
        HandleExtensionMethod(ctx context.Context, method string, params json.RawMessage) (any, error)
    }
    
    // Outbound (available on both AgentSideConnection and ClientSideConnection):
    resp, err := acp.CallExtension[MyResp](conn, ctx, "_vendor.example/echo", req)
    err = conn.NotifyExtension(ctx, "_vendor.example/event", payload)

    Unhandled extension requests automatically return MethodNotFound per spec; unhandled extension notifications are silently ignored (no more noisy log line).

  • Unstable schema support (#17 by @ThomasK33). The generator now also consumes schema.unstable.json / meta.unstable.json and emits unstable-only RPCs and types behind an Unstable* prefix, exposed via the existing AgentExperimental / ClientExperimental interfaces. Stable types and method signatures are untouched.

  • $/cancel_request cancellation (#17 by @ThomasK33). Inbound requests now run with a per-request context.Context; receiving $/cancel_request cancels that context. When an outbound caller's ctx is canceled while waiting for a response, the SDK best-effort sends $/cancel_request to the peer. Canceled handlers map to JSON-RPC error -32800.

  • Typed unstable session metadata (#26 by @carsonfarmer). Clients can now distinguish session config selectors by identity instead of treating them as opaque selects:

    • SessionConfigOptionSelect exposes id, name, optional description/category, type, currentValue, and options.
    • SessionCapabilities carries typed unstable markers (fork, list, resume).
    • NewSessionResponse includes optional typed configOptions and models.
    • UnstableResumeSessionResponse includes typed configOptions, models, and modes.

Changed

  • ACP schema bumped 0.6.3 → 0.10.8 (#15, #26 by @ThomasK33, @carsonfarmer). All *_gen.go files are regenerated; expect new methods/types on the stable surface (e.g. SetSessionConfigOption) and updated request/response shapes. The example/ agent and tests have been updated accordingly — see example/agent/main.go for the minimal stub pattern (return ..., acp.NewMethodNotFound(...) for unsupported optional methods).
  • Code generator hardening (#15, #17, #26). Handles JSON Schema allOf wrappers, preserves union variants that wrap $ref in allOf, deterministically avoids nested type-name collisions, fixes union UnmarshalJSON for unions whose variants can be primitives (notably RequestId), and propagates shared parent-object fields onto generated union variant structs.

Fixed

  • Prompt() returning before SessionUpdate handlers complete (#5 by @midsbie). SendRequest / SendRequestNoResult now wait for in-flight notification handlers before returning, so callers consistently observe all session updates that arrived before the response.
  • Out-of-order notifications (#8 by @krulsaidme0w). Notifications are queued and processed by a single goroutine, preserving wire order for streaming session/update traffic. Public API unchanged.
  • Deadlock on nested requests from a handler (#10 by @agentcooper, fixes #9). The notification WaitGroup no longer tracks request messages, so a handler can issue requests back to its peer without blocking forever.

Breaking Changes

The schema jump from 0.6.3 to 0.10.8 changes generated APIs. Most notably, the stable Agent interface gained methods such as SetSessionConfigOption, and a number of request/response struct shapes evolved with the protocol. Implementors of Agent / Client should regenerate against this release and add stubs (returning acp.NewMethodNotFound(...) is fine for optional methods, as shown in example/agent/main.go). Direct field-by-field migration guidance is best derived from the regenerated *_gen.go diffs.

New Contributors

Full Changelog: v0.6.3...v0.10.8

Don't miss a new acp-go-sdk release

NewReleases is sending notifications on new releases.