Skip to content

feat: add scope-owned versioned prompt management #1465

Description

@Teingi

Feature description

Add a Scope-owned Prompt Artifact family so each PowerContext Scope can customize the operational prompts used by Memory, Experience, Skill, and Handoff generation while retaining immutable revision history.

The initial registered prompt keys are:

  • memory.extract
  • memory.rerank
  • experience.incubate
  • experience.generate
  • skill.generate
  • handoff.generate

Each Prompt revision contains a mode, instructions, and typed demonstrations. A demonstration uses the formal fields input and expected_output; dashboard groupings such as positive and negative examples are presentation concerns rather than separate storage fields.

Problem and proposed solution

The built-in Runtime currently binds versioned instructions when it is composed. Different Agents or users can be bound to different Scopes, but the Scope itself cannot select a custom prompt, inspect its history, or reproduce which revision controlled an operation.

Use the existing Scope and Artifact revision model instead of introducing prompt-specific persistence:

  • add prompt as an Artifact family;
  • use each registered prompt key as the stable artifact_id;
  • reuse the existing create, current read, replace with If-Match, and exact revision read operations;
  • add GET /v1/scopes/{scope_id}/artifacts/{family}/{artifact_id}/revisions for generic revision history;
  • add POST /v1/scopes/{scope_id}/prompts/{prompt_key}/demonstrations to generate structured demonstration suggestions without saving them;
  • implement rollback by reading an old immutable revision and replacing the current head with that content, producing a new monotonically increasing revision;
  • resolve and freeze one exact Prompt revision at the start of each inference operation;
  • preserve Server-owned safety rules, output schemas, credentials, tool authority, and model configuration outside editable Prompt content.

No Prompt revision in a Scope means the current built-in behavior remains unchanged. There is no implicit parent-Scope inheritance or Agent/User-specific storage in the core contract.

Alternatives considered

  • Dedicated Prompt, Prompt Version, and Prompt Binding tables duplicate ownership, revision, and head semantics already supplied by Artifact storage.
  • Prompt-specific CRUD endpoints duplicate the generic Artifact API and make the surface harder to extend.
  • Agent- or user-keyed Prompt configuration conflicts with Scope isolation; Agent and user integrations should resolve their existing Scope binding before calling the core API.
  • Raw prompt replacement per inference request is difficult to authorize, audit, reproduce, and cache.
  • Informal positive/negative example fields couple the persistence contract to one dashboard layout and do not express the typed model input/output contract.

Additional context

The design will be submitted as a bilingual RFC before implementation. The RFC will define the exact content schema, HTTP contract, Runtime resolution rules, security boundaries, compatibility behavior, failure semantics, version history, and validation requirements.

Are you willing to contribute to this feature?

  • Yes, I am willing to contribute code, docs, or design feedback.

Activity

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

    enhancementNew feature or request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions