Skip to content

effect: Effect bridge package (LanguageModel over gateway + agent, schema interop, scoped sandbox layers) #144

Description

@ThomasK33

Tracking issue for an Effect bridge to the Coder AI SDK — a new packages/effect package (@coder/ai-sdk-effect) exposing the three existing packages through Effect-native abstractions.

Architecture

The bridge adapts our imperative SDK surfaces to Effect's service/Layer/Stream model without changing the underlying packages:

  • LanguageModel service over AI Gateway (@coder/ai-sdk-provider): implement Effect's LanguageModel interface on top of the gateway endpoints, mapping Effect Prompt/Response to the provider's chat-completions/messages calls and HTTP failures to typed AiErrors (auth, quota, provider-unavailable, malformed-response), preserving the centralized vs BYOK auth modes.
  • Schema interop: helpers bridging Standard Schema / Effect Schema to the SDK's tool-definition and structured-output surfaces, so Effect users define tools and output schemas in Effect Schema and get correct wire types both directions.
  • Scoped resource management for sandboxes (@coder/ai-sdk-sandbox): ensureCoderWorkspace + session lifecycle as Effect.acquireRelease / scoped Layers, so workspace acquisition, agent-readiness waits, and teardown compose with Effect scopes and interruption.
  • LanguageModel over CoderAgent/chatd (@coder/ai-sdk-agent): server-side agent loop as an Effect service — TurnTranslator output mapped onto Effect Stream, fiber interruption wired to agent.interrupt(), and the SDK's retryable/terminal error taxonomy (CoderStreamError.isRetryable, timeout vs cancellation) surfaced as tagged errors usable with Effect retry policies.

Roadmap

Phase 1 — Spike (in flight)

  • packages/effect scaffold (private, excluded from release-please until graduation)
  • Effect LanguageModel implementation over @coder/ai-sdk-provider (AI Gateway): Prompt/Response mapping + typed AiError hierarchy for HTTP errors
  • Standard Schema / Effect Schema interop helpers for tool definitions and structured outputs
  • Scoped Layers for workspace sandbox lifecycle (ensureCoderWorkspace + session as Effect.acquireRelease)
  • Unit tests + live validation against dev.coder.com

Phase 2

  • LanguageModel implementation over CoderAgent/chatd: TurnTranslatorEffect Stream mapping
  • Fiber interruption → agent.interrupt()
  • Retryable error tagging aligned with Effect retry policies
  • Publishing decision: versioning, peerDependency policy on effect/@effect/ai, release-please wiring

Notes

  • Spike ships as a private package: no npm publish and no release-please manifest entry until Phase 1 review concludes the API shape is right.
  • Effect / @effect/ai are fast-moving; the spike should pin exact versions and record the pinned API surface in the package README.

Generated with mux • Model: anthropic:claude-fable-5 • Thinking: xhigh

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedTriaged and accepted by a maintainerenhancementNew feature or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions