Spectre.Prompt (Spectre v0.3.0)

Copy Markdown View Source

Prompt resolver, renderer, and typed composition boundary.

A base ask prompt is represented as the task section of a Spectre.Prompt.Plan. Agent, Skill, Flow, and handler inject declarations resolve into typed fragments before model capability negotiation. Dynamic providers remain context data, while static instruction/task assets retain instruction trust. Policy request tasks cannot be replaced by application injections at any scope.

These rules prevent privilege promotion and policy bypass inside Spectre. Structured adapters preserve them at the adapter boundary; legacy adapters receive an escaped data marker. Neither form claims that the downstream model is immune to semantic jailbreaks.

Summary

Functions

Builds the fully resolved prompt plan used by a model call.

Resolves, composes, and renders a prompt for a model-backed turn.

Resolves a prompt name or relative path under the active definition's prompt root.

Functions

build(agent, prompt, ctx, opts \\ [])

@spec build(module(), atom() | String.t(), Spectre.Context.t() | map(), keyword()) ::
  {:ok, Spectre.Prompt.Plan.t()} | {:error, term()}

Builds the fully resolved prompt plan used by a model call.

render(agent, prompt, ctx, opts \\ [])

@spec render(module(), atom() | String.t(), Spectre.Context.t() | map(), keyword()) ::
  {:ok, String.t()} | {:error, term()}

Resolves, composes, and renders a prompt for a model-backed turn.

{:ok, text} = Spectre.Prompt.render(MyAgent, :welcome, ctx)

resolve(agent, prompt, ctx, opts \\ [])

@spec resolve(module(), atom() | String.t(), Spectre.Context.t() | map(), keyword()) ::
  {:ok, String.t()} | {:error, term()}

Resolves a prompt name or relative path under the active definition's prompt root.

Policy prompts are looked up under policies/<policy>/<prompt>.text.heex. Resolved paths must remain inside the configured root.