Skip to content

Completers as a first class option in Prompts #1474

Open

Description

@mattzcarey

One thought for a potential follow-up: now that the SDK is moving to schema-library-agnostic types, the completable() API could be simplified to decouple it from Zod entirely.

Instead of embedding completion callbacks inside schema objects (which requires Zod-specific introspection to extract), completers could be passed explicitly in the prompt config:

server.registerPrompt('greeting', {
  argsSchema: type({ name: 'string', language: 'string' }),  // any library
  completers: {
    name: (value) => ['Alice', 'Bob'].filter(n => n.startsWith(value)),
    language: (value) => ['en', 'fr'].filter(l => l.startsWith(value))
  }
}, callback);

The type simplifies too, since completion values are always strings over the wire:

type CompleteCallback = (
  value: string,
  context?: { arguments?: Record<string, string> }
) => string[] | Promise<string[]>;

This PR already does most of the internal plumbing — RegisteredPrompt stores completers?: Map<string, CompleteCallback>. The remaining step would be accepting them in the config directly, which would let us deprecate completable(), extractCompleters, and the Zod-specific helpers (getZodSchemaShape, unwrapZodOptionalSchema, etc.).

Not suggesting this as a blocker for this PR — just flagging as a natural follow-up that would complete the schema-agnostic story.

Originally posted by @felixweinberger in #1473 (comment)

Activity

  1. ghost added
    enhancement
    on Apr 16, 2026
  2. ghost added
    needs decision
    on Apr 16, 2026
  3. ghost added
    P3
    on Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3enhancementneeds decision

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions