Skip to content

feat: updates prompts plugin flow#2545

Merged
akshaydeo merged 7 commits intov1.5.0from
04-07-feat_updates_prompts_plugin_flow
Apr 16, 2026
Merged

feat: updates prompts plugin flow#2545
akshaydeo merged 7 commits intov1.5.0from
04-07-feat_updates_prompts_plugin_flow

Conversation

@roroghost17
Copy link
Copy Markdown
Contributor

@roroghost17 roroghost17 commented Apr 7, 2026

Changes

Refactors the prompts plugin to improve error handling, simplify the resolver interface, and add support for enterprise prompts plugin routing. The changes prepare the plugin for better integration with enterprise features while maintaining backward compatibility.

  • Simplified PromptResolver interface: Removed versionSpecified boolean return value from Resolve method and simplified version resolution logic
  • Added enterprise support: Added BifrostContextKeyPromptsPluginName context key and routing logic to support enterprise prompts plugin selection
  • Removed streaming logic: Eliminated BifrostContextKeyPromptStreamRequest and related stream detection from model parameters in transport hooks
  • Interface standardization: Changed promptStore to exported InMemoryStore interface for better extensibility
  • Enhanced context tracking: Added BifrostContextKeySelectedPromptName, BifrostContextKeySelectedPromptVersion, and BifrostContextKeySelectedPromptID for governance and observability
  • Updated header names: Changed prompt headers from bf-prompt-id/bf-prompt-version to x-bf-prompt-id/x-bf-prompt-version
  • Refactored version resolution: Simplified resolveVersion method to handle explicit version numbers vs latest version more clearly
  • Improved documentation: Added comprehensive package and function documentation throughout the plugin

Type of change

  • Refactor
  • Feature

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Plugins
  • UI (Next.js)

How to test

# Core/Transports
go version
go test ./...

# UI
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build

Test prompt resolution with both header-based and custom resolvers. Verify enterprise prompts plugin routing works when BifrostContextKeyPromptsPluginName is set.

Breaking changes

  • Yes

The PromptResolver interface signature changed from Resolve(ctx, req) (string, int, bool, error) to Resolve(ctx, req) (string, int, error). Custom resolver implementations will need to be updated to remove the versionSpecified boolean return value. Additionally, prompt headers changed from bf-prompt-id/bf-prompt-version to x-bf-prompt-id/x-bf-prompt-version.

Security considerations

No security implications - this is an internal refactoring that maintains the same access patterns and validation logic.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 7, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • More consistent prompt selection and version resolution behavior across requests.
    • Streaming now follows the request's explicit stream field (no implicit stream fallback).
  • Improvements

    • Prompt-related headers standardized to X-Bf-Prompt-Id / X-Bf-Prompt-Version for consistency.
    • Built-in prompts plugin registration tightened for enterprise/config store scenarios.
    • Prompt deployment caching improved with a new invalidation tag.

Walkthrough

Prompts plugin and related server/transport code were updated: prompt resolver signatures simplified, prompt-stream request flag removed, new context keys for selected prompt metadata added, prompt headers renamed to x-bf-prompt-*, an exported InMemoryStore introduced, and prompts plugin registration made conditional on enterprise/config store state.

Changes

Cohort / File(s) Summary
Context Keys & Constants
core/schemas/bifrost.go
Added BifrostContextKeySelectedPromptName, BifrostContextKeySelectedPromptVersion, BifrostContextKeySelectedPromptID, BifrostContextKeyPromptsPluginName; removed BifrostContextKeyPromptStreamRequest.
Prompts Plugin Core
plugins/prompts/main.go
Renamed headers to x-bf-prompt-id/x-bf-prompt-version; introduced exported InMemoryStore interface; changed PromptResolver.Resolve to return (string, int, error) (removed versionSpecified); removed prompt-stream selection logic and simplified version resolution and context parsing.
Prompts Tests & Helpers
plugins/prompts/helpers_test.go, plugins/prompts/plugin_test.go
Updated staticResolver and tests to remove versionSpecified; changed resolver return types; removed stream/SSE-related tests; adjusted header case tests.
HTTP Transport Inference
transports/bifrost-http/handlers/inference.go
effectiveStream no longer reads prompt-stream from Bifrost context; streaming decisions now depend only on request stream field.
HTTP Server Plugin Management
transports/bifrost-http/server/plugins.go, transports/bifrost-http/server/server.go
Prompts plugin registration now requires s.Config.ConfigStore != nil and non-enterprise context; added getPromptsPluginName() to read plugin name from context and used it for plugin discovery (type parameter adjusted for reloader lookup).
UI Minor Updates
ui/components/prompts/fragments/settingsPanel.tsx, ui/lib/store/apis/baseApi.ts
Imported VariablesTableView; added "PromptDeployments" to RTK Query baseApi tagTypes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐇 I hopped through code with eager paws,

New keys and headers, changed the laws,
Streams no longer whisper "true",
Prompts now wear a clearer hue,
Plugins wake where non-enterprise draws.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'feat: updates prompts plugin flow' is vague and lacks specificity about the primary changes; it uses generic phrasing that doesn't convey meaningful information about the refactoring or new features. Use a more specific title such as 'refactor: simplify PromptResolver interface and add enterprise plugin routing' to clearly summarize the main changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description covers all required template sections with substantial detail: it explains the purpose, lists specific changes with rationale, marks type of change, affected areas, provides testing instructions, documents breaking changes with migration guidance, and addresses security considerations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 04-07-feat_updates_prompts_plugin_flow

Comment @coderabbitai help to get the list of available commands and usage tips.

@roroghost17 roroghost17 force-pushed the 04-07-refactor_extracts_routing_utilites_to_a_separate_package branch from 7e6de90 to ea62825 Compare April 7, 2026 11:43
@roroghost17 roroghost17 force-pushed the 04-07-feat_updates_prompts_plugin_flow branch from 9917544 to 5f923f9 Compare April 7, 2026 11:43
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@roroghost17 roroghost17 force-pushed the 04-07-feat_updates_prompts_plugin_flow branch from 5f923f9 to face6b2 Compare April 7, 2026 14:20
@roroghost17 roroghost17 force-pushed the 04-07-refactor_extracts_routing_utilites_to_a_separate_package branch 2 times, most recently from 869bf55 to e65dccc Compare April 7, 2026 14:22
@roroghost17 roroghost17 force-pushed the 04-07-feat_updates_prompts_plugin_flow branch from face6b2 to 44734e7 Compare April 7, 2026 14:22
@roroghost17 roroghost17 force-pushed the 04-07-refactor_extracts_routing_utilites_to_a_separate_package branch from e65dccc to 633d32f Compare April 7, 2026 19:50
@roroghost17 roroghost17 force-pushed the 04-07-feat_updates_prompts_plugin_flow branch from 44734e7 to 369f154 Compare April 7, 2026 19:50
@roroghost17 roroghost17 force-pushed the 04-07-refactor_extracts_routing_utilites_to_a_separate_package branch from 633d32f to 66cc058 Compare April 9, 2026 13:20
@roroghost17 roroghost17 force-pushed the 04-07-feat_updates_prompts_plugin_flow branch from 369f154 to 56330d2 Compare April 9, 2026 13:20
@roroghost17 roroghost17 force-pushed the 04-07-refactor_extracts_routing_utilites_to_a_separate_package branch from 66cc058 to f37eed7 Compare April 9, 2026 13:22
@roroghost17 roroghost17 force-pushed the 04-07-feat_updates_prompts_plugin_flow branch 3 times, most recently from 4f1cda0 to 5c75f3d Compare April 10, 2026 07:03
@roroghost17 roroghost17 force-pushed the 04-07-refactor_extracts_routing_utilites_to_a_separate_package branch from f37eed7 to 4416453 Compare April 10, 2026 07:03
@roroghost17 roroghost17 marked this pull request as ready for review April 10, 2026 07:24
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 10, 2026

Confidence Score: 4/5

Not safe to merge as-is: the UI build will fail due to missing destructuring in settingsPanel.tsx.

One P0 build-breaking issue in the UI component prevents the PR from shipping. The Go backend changes are clean and well-tested; the single fix needed is adding variables and setVariables to the usePromptContext() destructuring in settingsPanel.tsx.

ui/components/prompts/fragments/settingsPanel.tsx — missing variables and setVariables destructuring from usePromptContext().

Important Files Changed

Filename Overview
ui/components/prompts/fragments/settingsPanel.tsx References variables and setVariables that are not destructured from usePromptContext(), causing a compile-time TypeScript error and preventing the UI from building.
plugins/prompts/main.go Refactored PromptResolver interface (removed versionSpecified bool), added parseNumberFromContext for correct string-to-int version parsing, added governance context keys, and renamed headers to x-bf-* prefix. Logic is sound.
core/schemas/bifrost.go Added BifrostContextKeySelectedPromptName, BifrostContextKeySelectedPromptVersion, BifrostContextKeySelectedPromptID, BifrostContextKeyPromptsPluginName, and BifrostContextKeyIsEnterprise context keys. Straightforward additions with clear documentation comments.
transports/bifrost-http/server/plugins.go Prompts plugin now skipped in enterprise mode (guarded by BifrostContextKeyIsEnterprise), consistent with governance plugin pattern.
plugins/prompts/plugin_test.go Comprehensive new test suite covering loadCache, PreLLMHook, HTTPTransportPreHook, resolveVersion, parseNumberFromContext, and merge helpers; all tests align with the new interface signature.
plugins/prompts/helpers_test.go New test helpers and mock types (MockLogger, mockStore, staticResolver, message builders) cleanly support the test suite; no issues.
ui/lib/store/apis/baseApi.ts Added PromptDeployments to the RTK Query tagTypes list; a routine, low-risk addition.

Comments Outside Diff (1)

  1. ui/components/prompts/fragments/settingsPanel.tsx, line 173-178 (link)

    P0 variables and setVariables are not in scope

    variables and setVariables are referenced here but were never destructured from usePromptContext(). Both identifiers are available in the context (defined in PromptContextValue), so they just need to be added to the destructuring at the top of the component. As written, this will produce a TypeScript compile error (Cannot find name 'variables') and crash the UI build.

Reviews (13): Last reviewed commit: "feat: updates prompts plugin flow" | Re-trigger Greptile

Comment thread plugins/prompts/main.go
Copy link
Copy Markdown
Contributor Author

@coderabbitai help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 12, 2026

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 12, 2026

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
plugins/prompts/main.go (1)

214-217: Docstring contract for PreLLMHook is stale versus implementation.

The comment says resolution/missing prompt/version returns an error, but the code logs warnings and returns unchanged request with nil error.

Also applies to: 224-240

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/prompts/main.go` around lines 214 - 217, The docstring for PreLLMHook
(and the similar block around lines 224-240) claims resolution/missing
prompt/version returns an error, but the implementation currently logs a warning
and returns the original *schemas.BifrostRequest with a nil error; update the
documentation to match the code or change the code to return an error—pick one
approach. Concretely, either (A) edit the comment for PreLLMHook and the related
docblock to state that resolution failures or invalid/empty templates will be
logged and result in returning the unchanged request with nil error, or (B)
modify PreLLMHook to return an error on resolution/missing prompt/version and
adjust callers accordingly; reference PreLLMHook to locate the implementation
and update the comments at the top of the file to keep the contract consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@plugins/prompts/main.go`:
- Around line 61-62: The PromptVersionKey is stored as a string in the write
path but read with bifrost.GetIntFromContext (which only type-asserts to int),
causing the version header to be ignored; fix by converting the stored string to
an int when reading: fetch the raw value from context (PromptVersionKey) as a
string (or use bifrost.GetStringFromContext if available), parse it to an int
(e.g., strconv.Atoi) and return that as versionNumber in the function that
returns promptID, versionNumber, nil; alternatively, ensure the write path
stores an int under PromptVersionKey so bifrost.GetIntFromContext
succeeds—update either the setter call that writes PromptVersionKey or the
getter path where versionNumber is obtained accordingly.

---

Nitpick comments:
In `@plugins/prompts/main.go`:
- Around line 214-217: The docstring for PreLLMHook (and the similar block
around lines 224-240) claims resolution/missing prompt/version returns an error,
but the implementation currently logs a warning and returns the original
*schemas.BifrostRequest with a nil error; update the documentation to match the
code or change the code to return an error—pick one approach. Concretely, either
(A) edit the comment for PreLLMHook and the related docblock to state that
resolution failures or invalid/empty templates will be logged and result in
returning the unchanged request with nil error, or (B) modify PreLLMHook to
return an error on resolution/missing prompt/version and adjust callers
accordingly; reference PreLLMHook to locate the implementation and update the
comments at the top of the file to keep the contract consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 304abd90-784a-402a-8405-c62650f3793f

📥 Commits

Reviewing files that changed from the base of the PR and between fe6f971 and 272618a.

📒 Files selected for processing (10)
  • core/schemas/bifrost.go
  • core/utils.go
  • plugins/prompts/helpers_test.go
  • plugins/prompts/main.go
  • plugins/prompts/plugin_test.go
  • transports/bifrost-http/handlers/inference.go
  • transports/bifrost-http/server/plugins.go
  • transports/bifrost-http/server/server.go
  • ui/components/prompts/fragments/settingsPanel.tsx
  • ui/lib/store/apis/baseApi.ts
✅ Files skipped from review due to trivial changes (2)
  • core/utils.go
  • ui/lib/store/apis/baseApi.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • ui/components/prompts/fragments/settingsPanel.tsx
  • plugins/prompts/helpers_test.go

Comment thread plugins/prompts/main.go Outdated
@roroghost17 roroghost17 force-pushed the 04-07-feat_updates_prompts_plugin_flow branch from 272618a to 53dd746 Compare April 15, 2026 21:42
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
plugins/prompts/main.go (2)

246-250: ⚠️ Potential issue | 🟡 Minor

Set the selected prompt ID independently of the display name.

SelectedPromptID is currently gated by prompt.Name != "", so a prompt with a blank name loses its stable identifier even though a version was resolved and applied. The ID should be written whenever prompt != nil; only the name needs the extra guard.

Suggested fix
-	if prompt != nil && prompt.Name != "" {
-		ctx.SetValue(schemas.BifrostContextKeySelectedPromptID, prompt.ID)
-		ctx.SetValue(schemas.BifrostContextKeySelectedPromptName, prompt.Name)
-	}
+	if prompt != nil {
+		ctx.SetValue(schemas.BifrostContextKeySelectedPromptID, prompt.ID)
+		if prompt.Name != "" {
+			ctx.SetValue(schemas.BifrostContextKeySelectedPromptName, prompt.Name)
+		}
+	}
 	ctx.SetValue(schemas.BifrostContextKeySelectedPromptVersion, strconv.Itoa(version.VersionNumber))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/prompts/main.go` around lines 246 - 250, The code incorrectly only
sets SelectedPromptID when prompt.Name != "" so prompts with empty names lose
their ID; change the logic so that
ctx.SetValue(schemas.BifrostContextKeySelectedPromptID, prompt.ID) is executed
whenever prompt != nil, while keeping the guard for setting
schemas.BifrostContextKeySelectedPromptName so the name is only written if
prompt.Name != ""; ensure
ctx.SetValue(schemas.BifrostContextKeySelectedPromptVersion,
strconv.Itoa(version.VersionNumber)) remains unchanged and still uses version.

446-490: ⚠️ Potential issue | 🟡 Minor

Negative prompt versions still resolve to “latest”.

A malformed x-bf-prompt-version: -1 — or a buggy custom PromptResolver returning -1 — falls through the versionNumber > 0 check and silently selects LatestVersion. That should fail closed instead of behaving like “latest”.

Suggested fix
 func (p *Plugin) resolveVersion(promptID string, versionNumber int) (
 	*configstoreTables.TablePrompt, *configstoreTables.TablePromptVersion, bool,
 ) {
 	p.mu.RLock()
 	defer p.mu.RUnlock()

 	prompt, ok := p.promptsByID[promptID]
 	if !ok || prompt == nil {
 		return nil, nil, false
 	}
+	if versionNumber < 0 {
+		return prompt, nil, false
+	}
 	if versionNumber > 0 {
 		byNumber, ok := p.versionsByPromptAndNumber[promptID]
 		if !ok {
 			return nil, nil, false
 		}
@@
 	n, err := strconv.ParseInt(s, 10, 64)
 	if err != nil {
 		return 0, err
 	}
+	if n < 0 {
+		return 0, fmt.Errorf("%s must be non-negative", key)
+	}
 	return int(n), nil
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/prompts/main.go` around lines 446 - 490, The resolveVersion function
currently treats any non-positive versionNumber as "no explicit version" and
returns LatestVersion, which allows negative values like -1 to silently resolve
to latest; update resolveVersion (function name: resolveVersion) to explicitly
reject negative version numbers by adding a check that if versionNumber < 0 it
returns nil, nil, false (failing closed), while leaving versionNumber == 0
behavior unchanged; optionally you can also validate in parseNumberFromContext
if you prefer to surface a parsing error early, but the minimal fix is the
negative check inside resolveVersion before the existing versionNumber > 0
block.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@transports/bifrost-http/server/server.go`:
- Around line 1082-1083: The lookup using
getPromptsPluginName()/schemas.BifrostContextKeyPromptsPluginName is dead
because nothing ever writes that context key; either write the key during server
initialization or remove the fallback lookup. Fix by setting the prompts plugin
name into the server context with SetValue(...) at startup (where server is
built/initialized) so getPromptsPluginName() can read it, or if the feature
isn't ready, remove the lib.FindPluginAs[handlers.PromptCacheReloader] branch
that relies on getPromptsPluginName() and keep using prompts.PluginName only;
adjust references to handlers.PromptCacheReloader and lib.FindPluginAs
accordingly.

---

Duplicate comments:
In `@plugins/prompts/main.go`:
- Around line 246-250: The code incorrectly only sets SelectedPromptID when
prompt.Name != "" so prompts with empty names lose their ID; change the logic so
that ctx.SetValue(schemas.BifrostContextKeySelectedPromptID, prompt.ID) is
executed whenever prompt != nil, while keeping the guard for setting
schemas.BifrostContextKeySelectedPromptName so the name is only written if
prompt.Name != ""; ensure
ctx.SetValue(schemas.BifrostContextKeySelectedPromptVersion,
strconv.Itoa(version.VersionNumber)) remains unchanged and still uses version.
- Around line 446-490: The resolveVersion function currently treats any
non-positive versionNumber as "no explicit version" and returns LatestVersion,
which allows negative values like -1 to silently resolve to latest; update
resolveVersion (function name: resolveVersion) to explicitly reject negative
version numbers by adding a check that if versionNumber < 0 it returns nil, nil,
false (failing closed), while leaving versionNumber == 0 behavior unchanged;
optionally you can also validate in parseNumberFromContext if you prefer to
surface a parsing error early, but the minimal fix is the negative check inside
resolveVersion before the existing versionNumber > 0 block.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cf7c6158-a0b4-47d8-9281-a3cc76383d2d

📥 Commits

Reviewing files that changed from the base of the PR and between 272618a and 53dd746.

📒 Files selected for processing (10)
  • core/schemas/bifrost.go
  • core/utils.go
  • plugins/prompts/helpers_test.go
  • plugins/prompts/main.go
  • plugins/prompts/plugin_test.go
  • transports/bifrost-http/handlers/inference.go
  • transports/bifrost-http/server/plugins.go
  • transports/bifrost-http/server/server.go
  • ui/components/prompts/fragments/settingsPanel.tsx
  • ui/lib/store/apis/baseApi.ts
✅ Files skipped from review due to trivial changes (4)
  • ui/components/prompts/fragments/settingsPanel.tsx
  • ui/lib/store/apis/baseApi.ts
  • core/utils.go
  • plugins/prompts/helpers_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • plugins/prompts/plugin_test.go
  • transports/bifrost-http/server/plugins.go
  • transports/bifrost-http/handlers/inference.go

Comment thread transports/bifrost-http/server/server.go
@roroghost17 roroghost17 force-pushed the 04-07-refactor_extracts_routing_utilites_to_a_separate_package branch from d54ccca to dc92eb1 Compare April 16, 2026 08:05
@roroghost17 roroghost17 force-pushed the 04-07-feat_updates_prompts_plugin_flow branch from 53dd746 to 29a6458 Compare April 16, 2026 08:05
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (3)
transports/bifrost-http/server/server.go (1)

288-294: ⚠️ Potential issue | 🟠 Major

Verify the prompts-plugin name is populated before this lookup runs.

This only changes behavior if schemas.BifrostContextKeyPromptsPluginName is written on the server/bootstrap path before RegisterAPIRoutes. Otherwise the new enterprise routing silently falls back to prompts.PluginName, so the added branch is effectively inactive.

Run this read-only check against the current stacked branch:

#!/bin/bash
set -euo pipefail

echo "== Reads =="
rg -n --type go -C2 'BifrostContextKeyPromptsPluginName'

echo
echo "== Writes via BifrostContext.SetValue =="
rg -n --type go -C2 'SetValue\s*\(\s*(schemas\.)?BifrostContextKeyPromptsPluginName\b'

echo
echo "== Writes via context.WithValue =="
rg -n --type go -C2 'WithValue\s*\([^)]*BifrostContextKeyPromptsPluginName'

echo
echo "== Bootstrap and route registration =="
rg -n --type go -C3 'Bootstrap\(|RegisterAPIRoutes\('

Expected result: at least one reachable write before RegisterAPIRoutes(...)/getPromptsPluginName() on the enterprise startup path.

Based on learnings: Bifrost context key/value assignments are done with (*BifrostContext).SetValue(key, value), not with context.WithValue.

Also applies to: 1082-1084

plugins/prompts/main.go (2)

246-249: ⚠️ Potential issue | 🟠 Major

SelectedPromptID should not depend on prompt name presence.

If prompt.Name is empty, the code currently skips setting BifrostContextKeySelectedPromptID, which drops stable prompt identity metadata even though resolution succeeded.

Suggested fix
-	if prompt != nil && prompt.Name != "" {
-		ctx.SetValue(schemas.BifrostContextKeySelectedPromptID, prompt.ID)
-		ctx.SetValue(schemas.BifrostContextKeySelectedPromptName, prompt.Name)
-	}
+	if prompt != nil {
+		ctx.SetValue(schemas.BifrostContextKeySelectedPromptID, prompt.ID)
+		if prompt.Name != "" {
+			ctx.SetValue(schemas.BifrostContextKeySelectedPromptName, prompt.Name)
+		}
+	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/prompts/main.go` around lines 246 - 249, The current conditional
checks prompt.Name before setting BifrostContextKeySelectedPromptID which causes
the selected prompt ID to be omitted when the prompt has an empty name; change
the logic in the prompt resolution block so that
ctx.SetValue(schemas.BifrostContextKeySelectedPromptID, prompt.ID) is executed
whenever prompt != nil (independent of prompt.Name), and only conditionally set
ctx.SetValue(schemas.BifrostContextKeySelectedPromptName, prompt.Name) when
prompt.Name != "" to preserve stable identity while still avoiding empty name
metadata.

486-490: ⚠️ Potential issue | 🟡 Minor

Reject negative prompt versions instead of silently treating them as “latest.”

strconv.ParseInt accepts -1, and resolveVersion interprets non-positive as latest. That makes invalid negative header values behave like valid “latest” selection.

Suggested fix
 	n, err := strconv.ParseInt(s, 10, 64)
 	if err != nil {
 		return 0, err
 	}
+	if n < 0 {
+		return 0, fmt.Errorf("invalid %s: must be non-negative", key)
+	}
 	return int(n), nil
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/prompts/main.go` around lines 486 - 490, The parse block in
resolveVersion currently allows negative numbers (strconv.ParseInt on s) which
later get treated as "latest"; change the logic to explicitly reject negative
versions: after parsing s into n (the strconv.ParseInt result), if n < 0 return
a descriptive error (e.g., "invalid negative version") instead of returning 0,
nil; keep handling of zero/positive versions unchanged so only negative values
are rejected. Ensure the check references the parsed variable (n) and the
resolveVersion function so behavior is clear.
🧹 Nitpick comments (2)
plugins/prompts/plugin_test.go (1)

612-616: Remove obsolete specified expectation field from version parsing tests.

specified is no longer asserted after the resolver contract simplification, so keeping it now adds noise.

Also applies to: 623-629

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/prompts/plugin_test.go` around lines 612 - 616, Remove the obsolete
specified expectation from the version parsing tests by deleting the specified
field from the want struct (currently declared with fields num, specified,
wantErr) and removing all expectations and assertions that reference
want.specified in the test cases and checks (also remove the corresponding
specified entries in per-case literal structs around the other occurrences
noted). Update any test case literals and assertion logic in plugin_test.go (the
version parsing tests) so they only use num and wantErr.
plugins/prompts/main.go (1)

216-220: PreLLMHook docstring no longer matches behavior.

The comment says missing prompt/version returns an error, but implementation warns and returns (req, nil, nil). Please update the doc to avoid misleading integrators.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/prompts/main.go` around lines 216 - 220, Update the PreLLMHook
docstring to reflect actual behavior: state that missing prompt or version does
NOT return an error but logs a warning and returns (req, nil, nil); likewise
invalid or empty templates return the original request with a nil error. Mention
the function's return tuple semantics: first value is the possibly-modified
*schemas.BifrostRequest, second is always nil *schemas.LLMPluginShortCircuit,
and third is an error only for true resolution failures (not for missing
prompt/version or empty templates).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@plugins/prompts/main.go`:
- Around line 246-249: The current conditional checks prompt.Name before setting
BifrostContextKeySelectedPromptID which causes the selected prompt ID to be
omitted when the prompt has an empty name; change the logic in the prompt
resolution block so that ctx.SetValue(schemas.BifrostContextKeySelectedPromptID,
prompt.ID) is executed whenever prompt != nil (independent of prompt.Name), and
only conditionally set ctx.SetValue(schemas.BifrostContextKeySelectedPromptName,
prompt.Name) when prompt.Name != "" to preserve stable identity while still
avoiding empty name metadata.
- Around line 486-490: The parse block in resolveVersion currently allows
negative numbers (strconv.ParseInt on s) which later get treated as "latest";
change the logic to explicitly reject negative versions: after parsing s into n
(the strconv.ParseInt result), if n < 0 return a descriptive error (e.g.,
"invalid negative version") instead of returning 0, nil; keep handling of
zero/positive versions unchanged so only negative values are rejected. Ensure
the check references the parsed variable (n) and the resolveVersion function so
behavior is clear.

---

Nitpick comments:
In `@plugins/prompts/main.go`:
- Around line 216-220: Update the PreLLMHook docstring to reflect actual
behavior: state that missing prompt or version does NOT return an error but logs
a warning and returns (req, nil, nil); likewise invalid or empty templates
return the original request with a nil error. Mention the function's return
tuple semantics: first value is the possibly-modified *schemas.BifrostRequest,
second is always nil *schemas.LLMPluginShortCircuit, and third is an error only
for true resolution failures (not for missing prompt/version or empty
templates).

In `@plugins/prompts/plugin_test.go`:
- Around line 612-616: Remove the obsolete specified expectation from the
version parsing tests by deleting the specified field from the want struct
(currently declared with fields num, specified, wantErr) and removing all
expectations and assertions that reference want.specified in the test cases and
checks (also remove the corresponding specified entries in per-case literal
structs around the other occurrences noted). Update any test case literals and
assertion logic in plugin_test.go (the version parsing tests) so they only use
num and wantErr.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 259896eb-7a72-4b6a-a515-75cd5ffea10c

📥 Commits

Reviewing files that changed from the base of the PR and between 53dd746 and 29a6458.

📒 Files selected for processing (10)
  • core/schemas/bifrost.go
  • core/utils.go
  • plugins/prompts/helpers_test.go
  • plugins/prompts/main.go
  • plugins/prompts/plugin_test.go
  • transports/bifrost-http/handlers/inference.go
  • transports/bifrost-http/server/plugins.go
  • transports/bifrost-http/server/server.go
  • ui/components/prompts/fragments/settingsPanel.tsx
  • ui/lib/store/apis/baseApi.ts
✅ Files skipped from review due to trivial changes (3)
  • core/utils.go
  • ui/components/prompts/fragments/settingsPanel.tsx
  • ui/lib/store/apis/baseApi.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • transports/bifrost-http/server/plugins.go
  • plugins/prompts/helpers_test.go

@roroghost17 roroghost17 force-pushed the 04-07-feat_updates_prompts_plugin_flow branch from 29a6458 to 9cd0a3e Compare April 16, 2026 11:42
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
plugins/prompts/main.go (1)

477-490: ⚠️ Potential issue | 🟡 Minor

Reject negative prompt versions during parsing.

strconv.ParseInt accepts -1, and resolveVersion treats non-positive values as “latest”, so negative headers silently bypass explicit-version intent.

Suggested fix
 func parseNumberFromContext(ctx *schemas.BifrostContext, key schemas.BifrostContextKey) (num int, err error) {
 	s, ok := ctx.Value(key).(string)
 	if !ok {
 		return 0, nil
 	}
 	s = strings.TrimSpace(s)
 	if s == "" {
 		return 0, nil
 	}
 	n, err := strconv.ParseInt(s, 10, 64)
 	if err != nil {
 		return 0, err
 	}
+	if n < 0 {
+		return 0, fmt.Errorf("%s must be non-negative", key)
+	}
 	return int(n), nil
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/prompts/main.go` around lines 477 - 490, The parseNumberFromContext
function currently allows negative integers (because strconv.ParseInt accepts
"-1"), which lets negative prompt-version headers bypass explicit-version
handling in resolveVersion; update parseNumberFromContext to validate the parsed
int (in function parseNumberFromContext) and return a non-nil error when n < 0
(include a clear error message referencing the invalid negative value and the
provided context key) so callers like resolveVersion cannot treat negative
values as valid versions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@plugins/prompts/main.go`:
- Around line 217-220: Update the PreLLMHook comment to match actual behavior:
state that when a prompt/version is missing or resolution fails (or when a
template is invalid/empty), the function logs warnings and returns (req, nil,
nil) rather than returning an error; also update the adjacent doc block covering
the related cases (the comment span around lines referencing the same behavior)
so both descriptions consistently describe the nil-error, logged-warning
behavior for PreLLMHook.

---

Duplicate comments:
In `@plugins/prompts/main.go`:
- Around line 477-490: The parseNumberFromContext function currently allows
negative integers (because strconv.ParseInt accepts "-1"), which lets negative
prompt-version headers bypass explicit-version handling in resolveVersion;
update parseNumberFromContext to validate the parsed int (in function
parseNumberFromContext) and return a non-nil error when n < 0 (include a clear
error message referencing the invalid negative value and the provided context
key) so callers like resolveVersion cannot treat negative values as valid
versions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3f7fcc4c-20d6-4091-b88d-4bdf407014a7

📥 Commits

Reviewing files that changed from the base of the PR and between 29a6458 and 9cd0a3e.

📒 Files selected for processing (10)
  • core/schemas/bifrost.go
  • core/utils.go
  • plugins/prompts/helpers_test.go
  • plugins/prompts/main.go
  • plugins/prompts/plugin_test.go
  • transports/bifrost-http/handlers/inference.go
  • transports/bifrost-http/server/plugins.go
  • transports/bifrost-http/server/server.go
  • ui/components/prompts/fragments/settingsPanel.tsx
  • ui/lib/store/apis/baseApi.ts
✅ Files skipped from review due to trivial changes (3)
  • ui/components/prompts/fragments/settingsPanel.tsx
  • core/utils.go
  • ui/lib/store/apis/baseApi.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • transports/bifrost-http/server/plugins.go
  • plugins/prompts/plugin_test.go

Comment thread plugins/prompts/main.go
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 16, 2026
@roroghost17 roroghost17 force-pushed the 04-07-refactor_extracts_routing_utilites_to_a_separate_package branch from dc92eb1 to 6328594 Compare April 16, 2026 14:50
@roroghost17 roroghost17 force-pushed the 04-07-feat_updates_prompts_plugin_flow branch from 9cd0a3e to 423ec88 Compare April 16, 2026 14:50
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
plugins/prompts/main.go (1)

246-267: ⚠️ Potential issue | 🟠 Major

Move side effects after template validation to preserve no-op fallback behavior.

Line 252 mutates request params and Lines 246-250 mutate selected-prompt context before template conversion is validated. If conversion fails or yields empty template (Lines 260-267), the hook exits early but leaves partial state changes behind.

Proposed fix
-	if prompt != nil && prompt.Name != "" {
-		ctx.SetValue(schemas.BifrostContextKeySelectedPromptID, prompt.ID)
-		ctx.SetValue(schemas.BifrostContextKeySelectedPromptName, prompt.Name)
-	}
-	ctx.SetValue(schemas.BifrostContextKeySelectedPromptVersion, strconv.Itoa(version.VersionNumber))
-
-	// Apply model params from the version (version params are defaults; request params win).
-	switch {
-	case req.ChatRequest != nil:
-		applyVersionParamsToChatRequest(version, req.ChatRequest, p.logger)
-	case req.ResponsesRequest != nil:
-		applyVersionParamsToResponsesRequest(version, req.ResponsesRequest, p.logger)
-	}
-
 	template, err := chatMessagesFromVersionMessages(version.Messages)
 	if err != nil {
 		p.logger.Warn("prompts plugin: failed to convert version messages to chat messages: %v", err)
 		return req, nil, nil
 	}
 	if len(template) == 0 {
 		p.logger.Warn("prompts plugin: no template messages found for prompt %s version %d", promptID, version.VersionNumber)
 		return req, nil, nil
 	}
+
+	if prompt != nil {
+		ctx.SetValue(schemas.BifrostContextKeySelectedPromptID, prompt.ID)
+		if prompt.Name != "" {
+			ctx.SetValue(schemas.BifrostContextKeySelectedPromptName, prompt.Name)
+		}
+	}
+	ctx.SetValue(schemas.BifrostContextKeySelectedPromptVersion, strconv.Itoa(version.VersionNumber))
+
+	// Apply model params from the version (version params are defaults; request params win).
+	switch {
+	case req.ChatRequest != nil:
+		applyVersionParamsToChatRequest(version, req.ChatRequest, p.logger)
+	case req.ResponsesRequest != nil:
+		applyVersionParamsToResponsesRequest(version, req.ResponsesRequest, p.logger)
+	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/prompts/main.go` around lines 246 - 267, The hook currently mutates
request and context (calls to ctx.SetValue with
schemas.BifrostContextKeySelectedPromptID/Name/Version and the calls
applyVersionParamsToChatRequest/applyVersionParamsToResponsesRequest) before
validating the template via chatMessagesFromVersionMessages and checking
template length, leaving partial state on error/empty template; change the flow
so you first call chatMessagesFromVersionMessages(version.Messages) and return
early on error or empty template, and only after it succeeds assign ctx.SetValue
for SelectedPromptID/Name/Version (keeping strconv.Itoa(version.VersionNumber))
and then applyVersionParamsToChatRequest/applyVersionParamsToResponsesRequest so
no side effects occur when conversion fails or yields an empty template.
♻️ Duplicate comments (2)
plugins/prompts/main.go (2)

217-220: ⚠️ Potential issue | 🟡 Minor

Align PreLLMHook return docs with actual warn-and-continue behavior.

Line 219 says resolution/missing prompt-version returns errors, but implementation returns (req, nil, nil) with warnings (Lines 227-239 and 241-267). The comment should match runtime behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/prompts/main.go` around lines 217 - 220, Update the
comment/documentation for PreLLMHook to reflect its actual warn-and-continue
behavior: instead of stating that resolution failures or missing prompt/version
return an error, document that in those cases the function logs warnings and
returns (req, nil, nil) leaving the request unchanged; reference the PreLLMHook
implementation paths around the warning blocks (the checks that log and return
req,nil,nil) so the doc matches runtime behavior.

486-490: ⚠️ Potential issue | 🟡 Minor

Reject negative prompt versions instead of treating them as “latest”.

ParseInt accepts negatives, and resolveVersion treats non-positive values as latest (Line 456 onward). So x-bf-prompt-version: -1 currently bypasses explicit version selection silently.

Proposed fix
 	n, err := strconv.ParseInt(s, 10, 64)
 	if err != nil {
 		return 0, err
 	}
+	if n < 0 {
+		return 0, fmt.Errorf("%q must be non-negative", string(key))
+	}
 	return int(n), nil
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/prompts/main.go` around lines 486 - 490, The code in resolveVersion
uses strconv.ParseInt to parse the x-bf-prompt-version header and currently
treats negative values as "latest"; change the validation after parsing (the
block with strconv.ParseInt and the return int(n)) to explicitly reject negative
values by returning a clear error when n < 0 while keeping zero and positive
values valid; update the error message to mention an invalid negative prompt
version and reference the strconv.ParseInt call and the resolveVersion function
when locating where to add this check.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@plugins/prompts/main.go`:
- Around line 246-267: The hook currently mutates request and context (calls to
ctx.SetValue with schemas.BifrostContextKeySelectedPromptID/Name/Version and the
calls applyVersionParamsToChatRequest/applyVersionParamsToResponsesRequest)
before validating the template via chatMessagesFromVersionMessages and checking
template length, leaving partial state on error/empty template; change the flow
so you first call chatMessagesFromVersionMessages(version.Messages) and return
early on error or empty template, and only after it succeeds assign ctx.SetValue
for SelectedPromptID/Name/Version (keeping strconv.Itoa(version.VersionNumber))
and then applyVersionParamsToChatRequest/applyVersionParamsToResponsesRequest so
no side effects occur when conversion fails or yields an empty template.

---

Duplicate comments:
In `@plugins/prompts/main.go`:
- Around line 217-220: Update the comment/documentation for PreLLMHook to
reflect its actual warn-and-continue behavior: instead of stating that
resolution failures or missing prompt/version return an error, document that in
those cases the function logs warnings and returns (req, nil, nil) leaving the
request unchanged; reference the PreLLMHook implementation paths around the
warning blocks (the checks that log and return req,nil,nil) so the doc matches
runtime behavior.
- Around line 486-490: The code in resolveVersion uses strconv.ParseInt to parse
the x-bf-prompt-version header and currently treats negative values as "latest";
change the validation after parsing (the block with strconv.ParseInt and the
return int(n)) to explicitly reject negative values by returning a clear error
when n < 0 while keeping zero and positive values valid; update the error
message to mention an invalid negative prompt version and reference the
strconv.ParseInt call and the resolveVersion function when locating where to add
this check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 47207cee-18ce-4b4e-a021-9414c3ce08ea

📥 Commits

Reviewing files that changed from the base of the PR and between 9cd0a3e and 423ec88.

📒 Files selected for processing (9)
  • core/schemas/bifrost.go
  • plugins/prompts/helpers_test.go
  • plugins/prompts/main.go
  • plugins/prompts/plugin_test.go
  • transports/bifrost-http/handlers/inference.go
  • transports/bifrost-http/server/plugins.go
  • transports/bifrost-http/server/server.go
  • ui/components/prompts/fragments/settingsPanel.tsx
  • ui/lib/store/apis/baseApi.ts
✅ Files skipped from review due to trivial changes (2)
  • ui/components/prompts/fragments/settingsPanel.tsx
  • ui/lib/store/apis/baseApi.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • transports/bifrost-http/server/plugins.go
  • plugins/prompts/helpers_test.go
  • core/schemas/bifrost.go
  • plugins/prompts/plugin_test.go

@roroghost17 roroghost17 force-pushed the 04-07-refactor_extracts_routing_utilites_to_a_separate_package branch from 6328594 to a9ceab4 Compare April 16, 2026 15:52
@roroghost17 roroghost17 force-pushed the 04-07-feat_updates_prompts_plugin_flow branch from 423ec88 to 944dd72 Compare April 16, 2026 15:52
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
plugins/prompts/plugin_test.go (1)

488-499: Add the same literal/case-insensitive coverage for x-bf-prompt-version.

This test now protects the raw x-bf-prompt-id header rename, but the version-header path is still only exercised through PromptVersionHeader. If that literal regresses, the current version test can still pass because it uses the same constant on both setup and lookup.

🧪 Suggested test addition
 func TestHTTPTransportPreHook_CaseInsensitiveHeaders(t *testing.T) {
 	p := newTestPlugin(nil, nil, nil)
 	ctx := bfCtx()
 	// "X-Bf-Prompt-Id" is a title-case variant of the canonical "x-bf-prompt-id".
 	req := &schemas.HTTPRequest{
 		Headers: map[string]string{"X-Bf-Prompt-Id": "upper-case"},
 	}
 
 	_, _ = p.HTTPTransportPreHook(ctx, req)
 
 	got, _ := ctx.Value(PromptIDKey).(string)
 	assert.Equal(t, "upper-case", got)
 }
+
+func TestHTTPTransportPreHook_CaseInsensitiveVersionHeaders(t *testing.T) {
+	p := newTestPlugin(nil, nil, nil)
+	ctx := bfCtx()
+	req := &schemas.HTTPRequest{
+		Headers: map[string]string{"X-Bf-Prompt-Version": "42"},
+	}
+
+	_, _ = p.HTTPTransportPreHook(ctx, req)
+
+	got, _ := ctx.Value(PromptVersionKey).(string)
+	assert.Equal(t, "42", got)
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugins/prompts/plugin_test.go` around lines 488 - 499, Add a
case-insensitive check for the version header in
TestHTTPTransportPreHook_CaseInsensitiveHeaders by including the title-case
literal "X-Bf-Prompt-Version" in the req.Headers map (e.g.,
"X-Bf-Prompt-Version": "1.2") alongside "X-Bf-Prompt-Id", call
p.HTTPTransportPreHook(ctx, req) as before, and assert the context value
retrieved via ctx.Value(PromptVersionKey).(string) equals the expected version
string; this ensures the code path that reads x-bf-prompt-version is covered
independently of the PromptVersionHeader constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@plugins/prompts/plugin_test.go`:
- Around line 488-499: Add a case-insensitive check for the version header in
TestHTTPTransportPreHook_CaseInsensitiveHeaders by including the title-case
literal "X-Bf-Prompt-Version" in the req.Headers map (e.g.,
"X-Bf-Prompt-Version": "1.2") alongside "X-Bf-Prompt-Id", call
p.HTTPTransportPreHook(ctx, req) as before, and assert the context value
retrieved via ctx.Value(PromptVersionKey).(string) equals the expected version
string; this ensures the code path that reads x-bf-prompt-version is covered
independently of the PromptVersionHeader constant.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d10efb2f-ad9b-4d1d-9f2c-e6cef4b93cc7

📥 Commits

Reviewing files that changed from the base of the PR and between 423ec88 and 944dd72.

📒 Files selected for processing (9)
  • core/schemas/bifrost.go
  • plugins/prompts/helpers_test.go
  • plugins/prompts/main.go
  • plugins/prompts/plugin_test.go
  • transports/bifrost-http/handlers/inference.go
  • transports/bifrost-http/server/plugins.go
  • transports/bifrost-http/server/server.go
  • ui/components/prompts/fragments/settingsPanel.tsx
  • ui/lib/store/apis/baseApi.ts
✅ Files skipped from review due to trivial changes (3)
  • ui/components/prompts/fragments/settingsPanel.tsx
  • ui/lib/store/apis/baseApi.ts
  • plugins/prompts/main.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/schemas/bifrost.go

Copy link
Copy Markdown
Contributor

akshaydeo commented Apr 16, 2026

Merge activity

  • Apr 16, 4:34 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 16, 4:40 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo akshaydeo changed the base branch from 04-07-refactor_extracts_routing_utilites_to_a_separate_package to graphite-base/2545 April 16, 2026 16:39
@akshaydeo akshaydeo changed the base branch from graphite-base/2545 to v1.5.0 April 16, 2026 16:39
@akshaydeo akshaydeo dismissed coderabbitai[bot]’s stale review April 16, 2026 16:39

The base branch was changed.

@akshaydeo akshaydeo merged commit 4f81099 into v1.5.0 Apr 16, 2026
4 of 13 checks passed
@akshaydeo akshaydeo deleted the 04-07-feat_updates_prompts_plugin_flow branch April 16, 2026 16:40
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.

5 participants