Skip to content

feat(plugins): Add prompt hook contributions#621

Open
dcramer wants to merge 1 commit into
mainfrom
feat/plugin-prompt-hooks
Open

feat(plugins): Add prompt hook contributions#621
dcramer wants to merge 1 commit into
mainfrom
feat/plugin-prompt-hooks

Conversation

@dcramer

@dcramer dcramer commented Jun 19, 2026

Copy link
Copy Markdown
Member

Runtime plugins can now contribute bounded system and user prompt context through generic prompt hooks instead of memory-specific core APIs. The public plugin API exposes a platform-only system prompt context, request-scoped user prompt context, bounded JSON session appends, and shared validation schemas so plugin authors see the same contract core enforces.

Core renders accepted plugin prompt text inside Junior-owned wrappers and commits matching plugin session appends in the same durable input checkpoint as the model-visible prompt. Initial, follow-up, and steering user prompts run the same userPrompt path; the focused integration test exercises generateAssistantReply with only the Pi/model boundary faked, alongside unit coverage for validation, prompt rendering, and session-log projection behavior.

@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview, Comment Jun 19, 2026 4:02am

Request Review

pluginPrompt.sessionState,
),
};
}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Parallel steering plugin hooks race

Medium Severity

When several steering messages are injected in one batch, drainSteeringMessages runs getPluginUserPromptContributions for each message concurrently via Promise.all. Each hook reads the same plugin session snapshot and can emit identical prompt text and session appends before a single checkpoint, so bookkeeping and model context can disagree with sequential steering.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b072c14. Configure here.

Add generic plugin prompt hooks for system and user prompt context so runtime plugins can contribute bounded prompt text without owning prompt rendering. The public API now exposes platform-only system prompt context, request-scoped user prompt context, and bounded JSON session appends for deterministic prompt continuity.

Core collects and validates plugin contributions, renders them under Junior-owned wrappers, and commits accepted session appends with the same durable input checkpoint as the model-visible prompt. Follow-up and steering user prompts run the same userPrompt hook path, and focused integration coverage exercises generateAssistantReply with only the Pi/model boundary faked.

Co-authored-by: GPT-5 Codex <codex@openai.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 03ed059. Configure here.

? { contributions: [], sessionState: [] }
: await getPluginUserPromptContributions({
context: toolRuntimeContext,
isFirstPrompt: needsBootstrapContext,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

isFirstPrompt conflates bootstrap flag

Medium Severity

getPluginUserPromptContributions receives isFirstPrompt: needsBootstrapContext, but that flag only reflects whether prior Pi history includes a runtime turn-context block. Local (and other) flows strip that block from reused history while keeping earlier user turns, so follow-up messages still get isFirstPrompt: true even though they are not the first model-visible user prompt in the projection.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 03ed059. Configure here.

value: PluginJsonValue;
}>,
pluginName,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Session appends skipped without ID

Medium Severity

When a userPrompt hook returns accepted contributions and sessionState, core still renders the contributions if conversationId is missing, but it omits those appends from the durable checkpoint payload. session.list stays empty while the model already saw the prompt text, breaking bookkeeping that should commit together with accepted contributions.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 03ed059. Configure here.

@dcramer dcramer marked this pull request as ready for review June 19, 2026 04:09
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.

1 participant