feat(schema): prompt_version.template_messages (Plan A)#11
Merged
Conversation
Captures the brainstormed design for the playground redesign:
- prompt_version.template -> template_messages jsonb (replace, with one
release of legacy column for safe deploy/rollback)
- system + human messages only for v1; AI/tools/output_schema deferred
- Jinja {{ var }} substitution kept; no f-string selector
- single prompt panel; compare deferred to its own iteration
- save creates a new version always; "New prompt..." entry in the
picker handles the unloaded case
- empty variables render as empty string
Spec covers schema migration, request/response contracts,
web composer rewrite, dispatcher changes, error semantics, testing
strategy, and a 4-step rollout that lets each PR land independently.
Signed-off-by: Gaurav Dubey <gauravdubey0107@gmail.com>
Signed-off-by: gaurav0107 <gauravdubey0107@gmail.com>
Replace the single-string template with a structured list of typed
messages so the playground can compose system + human turns. Backfills
every existing row to [{role: 'human', content: <old template>}],
preserving exact behavior for prompts in production. Legacy 'template'
column kept for one release as a deploy/rollback safety net.
Companion to docs/superpowers/specs/2026-06-07-playground-messages-redesign-design.md.
Signed-off-by: Gaurav Dubey <gauravdubey0107@gmail.com>
Signed-off-by: gaurav0107 <gauravdubey0107@gmail.com>
…emplate Adds the structured Message model (system | human) and exposes both fields on PromptVersionOut so the playground (Plan B) and the web UI (Plan C) can read the new shape while existing clients keep seeing the legacy single-string field. The legacy field is derived from template_messages and is empty when the prompt has more than one message or any system message — better than lying. The router's hydration is centralized in _hydrate_version so the three SELECT paths share one row->model conversion. Companion to docs/superpowers/specs/2026-06-07-playground-messages-redesign-design.md. Signed-off-by: gaurav0107 <gauravdubey0107@gmail.com>
Pins the post-migration invariants - column exists NOT NULL, existing
rows have the [{role: human, content: <old template>}] wrap shape, and
the check constraint refuses an empty messages array. Skips cleanly
when the local db has no prompts to inspect.
Signed-off-by: gaurav0107 <gauravdubey0107@gmail.com>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Plan A of the playground messages redesign. Replaces the single-string
prompt_version.templatewith a structuredtemplate_messages jsonbcolumn. Backfill rewrites every existing row to a single-human-message
shape so production prompts keep loading unchanged.
The api response model carries both fields during one release of
back-compat; the legacy
templateis derived fromtemplate_messagesso old clients still work.
This PR is schema + read-path only. Plans B and C land the api
write path, the playground request shape, and the composer rewrite.
Files
schemas/postgres/migrations/0026_prompt_template_messages.sql— the migrationservices/api/tracebility_api/routers/prompts.py—Messagemodel,PromptVersionOutextended, hydration centralized in_hydrate_versionservices/api/tests/unit/test_prompt_response_shape.py— pydantic shape + hydration derivation testsservices/api/tests/integration/test_prompts_template_messages.py— live db invariants (column shape, backfill, CHECK constraint)docs/superpowers/specs/2026-06-07-playground-messages-redesign-design.md— specTest plan
Companion docs
🤖 Generated with Claude Code