Skip to content

feat(profile): support scoped custom prompts - #1541

Open
Zxf-xufeng wants to merge 1 commit into
masterfrom
codex/profile-custom-prompt
Open

feat(profile): support scoped custom prompts#1541
Zxf-xufeng wants to merge 1 commit into
masterfrom
codex/profile-custom-prompt

Conversation

@Zxf-xufeng

Copy link
Copy Markdown
Member

Which issue or RFC does this PR close?

Related to #1468, #1473, and #1536.

Rationale for this change

Scope-owned Prompt management supports Memory, Experience, Skill, and Handoff operations, but Profile generation still uses fixed server instructions. This leaves Profile as the remaining generated artifact that cannot apply scoped guidance or record the exact Prompt revision used for generation.

What changes are included in this PR?

  • Register profile.generate as a Prompt key with the existing Profile input/output contract and unchanged Auto instructions.
  • Bind the scoped Prompt selection around manual and automatic Profile flushes, including spawned family workers.
  • Pass compiled Custom instructions and demonstrations into the built-in structured generator.
  • Record the selected Custom Prompt artifact in both directly generated Profile lineage and review-required candidate lineage.
  • Keep evidence trust, person attribution, sensitive-attribute safeguards, and output shape as server-owned invariants.
  • Report injected ProfileGenerator components as unsupported for managed Prompt customization, matching the existing component capability model.
  • Update the OpenAPI-generated client models, bilingual workflow documentation, and behavior/E2E tests.

Are there any user-facing changes?

Yes. Clients can create or replace a Scope-owned Prompt artifact with prompt_key=profile.generate. The Prompt affects future Profile processing windows only; saving it does not reprocess historical Sources. This is additive and requires no data migration.

How was this change tested?

  • make check
  • make contract-test (47 passed)
  • Focused Prompt/Profile/runtime/HTTP tests (79 passed)
  • Full macOS-executable suite excluding Linux-only systemd receiver-service tests (2066 passed, 61 skipped)

AI usage statement

Implemented and reviewed with OpenAI Codex (GPT-5), including code analysis, test generation, and validation.

updated = await self.policies.update(connection, policy)
refs = tuple(item.ref for item in evidence)
parents = () if current is None else (current.as_ref(),)
artifacts = (*parents, *_profile_prompt_refs())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Reserve evidence capacity for the selected Prompt

With a Custom profile.generate Prompt and activation_mode="review_required", a full window exceeds the 32-reference candidate limit: 32 Sources + Prompt for the first Profile, or 31 Sources + previous Profile + Prompt for an update. I reproduced both on SQLite: each flush raises ValidationError: Candidate evidence must not exceed 32 references, and retrying invokes the generator again without advancing the cursor. Please reserve capacity for the Prompt when computing the Source window and cover both cases.

key="profile.generate",
definition_version="powercontext.prompt.profile.generate.v1",
input_type=ProfileGenerationInput,
output_type=ProfileGenerationOutput,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Validate Profile demonstration content against the runtime contract

ProfileGenerationOutput accepts blank strings, and validate_demonstration() has no Profile check. I verified that {"content":" "} is accepted by both demonstration generation and Prompt creation, while the built-in Profile generator returning the same output causes flush to raise InvalidInferenceOutputError during Markdown validation. Please apply the Profile Markdown validation to non-null demonstration outputs and use content=null for no-op examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants