Skip to content

docs: document PreRequestHook routing phase, per-request vs per-attempt semantics, and updated plugin sequencing - #3935

Merged
akshaydeo merged 1 commit into
devfrom
06-01-docs_update_docs_for_perrequesthook
Jun 9, 2026
Merged

docs: document PreRequestHook routing phase, per-request vs per-attempt semantics, and updated plugin sequencing#3935
akshaydeo merged 1 commit into
devfrom
06-01-docs_update_docs_for_perrequesthook

Conversation

@Pratham-Mishra04

@Pratham-Mishra04 Pratham-Mishra04 commented May 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

Documents the PreRequestHook plugin lifecycle phase introduced in v1.6.x. This hook runs exactly once per top-level request — before any provider call and before PreLLMHook — and is the designated place for routing decisions (provider/model/fallback resolution). Previously, routing documentation was scattered and the distinction between per-request and per-attempt hooks was not clearly articulated.

Changes

  • Added PreRequestHook to the plugin lifecycle state diagram, sequence diagrams, and execution order descriptions across the architecture and getting-started docs, clarifying that it runs once per request while PreLLMHook/PostLLMHook run once per provider attempt (including fallbacks)
  • Added a comparison table and <Info> callout explaining when to use PreRequestHook vs PreLLMHook vs PostLLMHook
  • Added a routing layer order table in sequencing.mdx documenting the built-in plugin execution order within PreRequestHook: governance (order 4) → enterprise load balancer → model-catalog-resolver (order 9, final fallback)
  • Added PreRequestHook function stubs and a full routing example (with AppendRoutingEngineLog and AppendToContextList) to the Go plugin writing guide
  • Updated the provider routing doc to reflect that all three routing layers (governance, enterprise LB Level 1, model-catalog-resolver) now execute inside the PreRequestHook phase rather than across separate middleware stages, and revised the flowcharts and execution order tables accordingly
  • Clarified that the model-catalog-resolver prefers the integration's canonical provider when the request arrived via an integration route, and updated the log message example to match

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

Review the rendered documentation pages for:

  • docs/architecture/core/plugins.mdx
  • docs/plugins/getting-started.mdx
  • docs/plugins/sequencing.mdx
  • docs/plugins/writing-go-plugin.mdx
  • docs/providers/provider-routing.mdx

Verify that the state diagram, sequence diagrams, and flowcharts render correctly and that the PreRequestHook phase is consistently described across all pages.

Breaking changes

  • Yes
  • No

Related issues

Security considerations

None.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

Summary by CodeRabbit

  • Documentation
    • Clarified plugin lifecycle: introduced a once-per-request routing phase and distinguished per-provider-attempt hooks, short-circuits, and fallback re-entry semantics.
    • Updated Go plugin guides and skeletons with routing-phase examples and a PreRequestHook stub.
    • Documented routing order, provider-resolution/fallback rules (catalog resolver as final fallback), empty-provider 400 validation, and cache/streaming pipeline behaviors.

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR documents PreRequestHook as a once-per-request routing-phase hook and updates architecture diagrams, plugin guides, Go examples, and provider-routing docs to show routing ordering, per-attempt semantics, fallback behavior, and validation after routing.

Changes

PreRequestHook Introduction and Clarification

Layer / File(s) Summary
Core plugin lifecycle and hook execution model
docs/architecture/core/plugins.mdx
Plugin lifecycle state diagram now explicitly shows the per-request routing phase where PreRequestHook executes separately from per-attempt phases. Fallback behavior re-enters at per-attempt without re-running PreRequestHook. Sequence diagrams annotated with "once per request" and "per provider attempt" notes for routing and per-attempt phases respectively, including cache-hit and streaming path clarifications.
Getting started with PreRequestHook API
docs/plugins/getting-started.mdx
PreRequestHook() (marked v1.6.x+) added to the plugin interface list for v1.4.x+ users. "Plugin Lifecycle" step descriptions reworked to present PreRequestHook as the once-per-request routing hook, with updated ordering and semantics for subsequent PreLLMHook() and PostLLMHook() calls.
Plugin hook sequencing and routing layer order
docs/plugins/sequencing.mdx
New "Routing layer order (PreRequestHook)" section documents the fixed builtin plugin execution order within the routing phase (governance, adaptive load balancer, then model-catalog-resolver) and explains req.Provider resolution/validation behavior. Next-steps link updated to include PreRequestHook implementation reference.
PreRequestHook code examples and reference documentation
docs/plugins/writing-go-plugin.mdx
Hello-world plugin skeletons for v1.5.x+ and v1.4.x now include PreRequestHook function stubs with routing-phase guidance. New comprehensive PreRequestHook(...) reference section (v1.6.x+) explains once-per-request execution, routing mutations (provider/model/fallback), comparison vs PreLLMHook, plugin ordering, non-blocking error semantics, and includes a routing example.
Provider routing integration with PreRequestHook phase
docs/providers/provider-routing.mdx
Governance, enterprise load balancing Level 1, and model-catalog-resolver execution consolidated into a single PreRequestHook phase diagram and narrative. Default provider resolution clarified as the final catalog-resolver layer (order 9) with canonical integration preference rule. "How Governance and Load Balancing Interact" section updated to show explicit skip conditions and execution order within the routing phase.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Suggested reviewers

  • akshaydeo
  • danpiths

Poem

🐰 I nudge the hooks where routes begin,
Once per request, I set the spin,
Per-attempt calls then take the stage,
Fallbacks resume—no re-run page,
Docs hum the path and tidy the lane.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main changes: documenting PreRequestHook's routing phase, clarifying per-request vs per-attempt semantics, and explaining updated plugin sequencing.
Description check ✅ Passed The description follows the template structure with Summary, Changes, Type of change, Affected areas, How to test, Breaking changes, Related issues, Security considerations, and Checklist sections all properly filled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 06-01-docs_update_docs_for_perrequesthook

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

@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.

@greptile-apps

greptile-apps Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Documentation-only change; all behavioral claims verified against the Go implementation and safe to merge.

Every documented API signature, constant, plugin order value, and behavioral claim was cross-checked against the live Go source. The two findings are cosmetic: a log message example with a spurious line break, and a routing example that reuses the governance plugin's reserved engine name for a custom plugin without explanation. Neither affects runtime behavior.

docs/plugins/writing-go-plugin.mdx and docs/providers/provider-routing.mdx have minor inaccuracies worth a second look before publishing.

Important Files Changed

Filename Overview
docs/architecture/core/plugins.mdx Adds PreRequestHook to state diagram, sequence diagrams, and execution order prose; semantics (non-blocking errors, once-per-request, fallback re-entry) match the core implementation.
docs/plugins/getting-started.mdx Plugin lifecycle and hook ordering correctly updated to include PreRequestHook as step 2 in the v1.4.x+ sequence; descriptions match the implementation.
docs/plugins/sequencing.mdx New routing-layer order table accurately reflects order values (governance=4, model-catalog-resolver=9) as confirmed in transports/bifrost-http/server/plugins.go; custom plugin placement guidance is correct.
docs/plugins/writing-go-plugin.mdx PreRequestHook stubs and routing example are accurate for signature, helper functions, and constants, but the routing example uses RoutingEngineRoutingRule ("routing-rule") — the reserved name for the governance CEL rules engine — for a custom plugin, which would produce ambiguous telemetry.
docs/providers/provider-routing.mdx Execution order table and flowcharts correctly updated to reflect all routing layers running inside PreRequestHook; log message example has a spurious line break that doesn't match the actual single-line Sprintf output from modelcatalogresolver.

Reviews (13): Last reviewed commit: "docs: update docs for perrequesthook" | Re-trigger Greptile

Comment thread docs/architecture/core/plugins.mdx Outdated
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-feat_add_model_catalog_router_plugin branch from e8352f5 to 856c996 Compare May 31, 2026 21:51
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-docs_update_docs_for_perrequesthook branch from 63d908a to 50e8ded Compare May 31, 2026 21:51
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-docs_update_docs_for_perrequesthook branch from 50e8ded to 7ad668e Compare June 1, 2026 09:53
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-feat_add_model_catalog_router_plugin branch 2 times, most recently from ceeb945 to a55b42c Compare June 1, 2026 11:01
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-docs_update_docs_for_perrequesthook branch 2 times, most recently from 53da3d4 to fff3d21 Compare June 3, 2026 11:26
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-feat_add_model_catalog_router_plugin branch from a55b42c to da3318a Compare June 3, 2026 11:26
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-feat_add_model_catalog_router_plugin branch from 05c2bc9 to d3f5a32 Compare June 5, 2026 09:48
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-docs_update_docs_for_perrequesthook branch 2 times, most recently from 2fd7c8c to 4edbac5 Compare June 7, 2026 07:25
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-feat_add_model_catalog_router_plugin branch from d3f5a32 to 3010c2b Compare June 7, 2026 07:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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)
docs/plugins/getting-started.mdx (1)

87-87: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Line 87 still collapses per-request and per-attempt hook semantics.

Please split this sentence so it explicitly says PreRequestHook() runs once per top-level request, while PreLLMHook() and PostLLMHook() run per provider attempt (including fallbacks).

As per coding guidelines, “PreRequestHook is once per request; PreLLMHook / PostLLMHook remain per provider attempt.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/plugins/getting-started.mdx` at line 87, Update the sentence describing
hook execution to clearly separate per-request vs per-attempt semantics: state
that PreRequestHook() runs once for the top-level request, while PreLLMHook()
and PostLLMHook() run for each provider attempt (including fallbacks); locate
the sentence mentioning "Hook Execution" and replace the combined line with two
short clauses that reference PreRequestHook(), PreLLMHook(), and PostLLMHook()
by name and explicitly note "once per request" for PreRequestHook() and "per
provider attempt (including fallbacks)" for PreLLMHook() and PostLLMHook().

Source: Coding guidelines

docs/plugins/writing-go-plugin.mdx (1)

155-163: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

PreRequestHook appears as part of v1.5.x+/v1.4.x skeleton API despite being v1.6.x+.

These skeleton blocks should either remove PreRequestHook from older-version tabs or clearly annotate it as optional/v1.6.x+ only in-code (not just elsewhere on the page), to avoid copy/paste confusion.

As per coding guidelines, “Provide a Go plugin skeleton and hook reference that correctly states PreRequestHook’s contract for v1.6.x+.”

Also applies to: 281-286

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/plugins/writing-go-plugin.mdx` around lines 155 - 163, Update the Go
plugin skeleton so PreRequestHook is not presented as part of older-version
tabs: either remove the PreRequestHook function block from v1.4.x/v1.5.x
skeletons or add an in-code annotation on the PreRequestHook declaration (the
func PreRequestHook(ctx *schemas.BifrostContext, req *schemas.BifrostRequest)
error) stating it is optional and only available in v1.6.x+; apply the same
change to the other instance referenced (lines around the second occurrence) and
ensure the comment explicitly marks the API contract as v1.6.x+ to prevent
copy/paste confusion.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/architecture/core/plugins.mdx`:
- Around line 74-75: The diagram currently shows PreRequestHook producing a
blocking ShortCircuitError; update the diagram so PreRequestHook error outcomes
are non-blocking warnings that rejoin the normal flow (remove or repoint the
PreRequestHookCall --> ShortCircuitError transition), change the label from
“Return Error” to “Log Warning” (or similar), and route the error path back into
the subsequent normal node (e.g., the ValidateProvider/next pipeline node) so
execution continues per the PreRequestHook contract.

---

Duplicate comments:
In `@docs/plugins/getting-started.mdx`:
- Line 87: Update the sentence describing hook execution to clearly separate
per-request vs per-attempt semantics: state that PreRequestHook() runs once for
the top-level request, while PreLLMHook() and PostLLMHook() run for each
provider attempt (including fallbacks); locate the sentence mentioning "Hook
Execution" and replace the combined line with two short clauses that reference
PreRequestHook(), PreLLMHook(), and PostLLMHook() by name and explicitly note
"once per request" for PreRequestHook() and "per provider attempt (including
fallbacks)" for PreLLMHook() and PostLLMHook().

In `@docs/plugins/writing-go-plugin.mdx`:
- Around line 155-163: Update the Go plugin skeleton so PreRequestHook is not
presented as part of older-version tabs: either remove the PreRequestHook
function block from v1.4.x/v1.5.x skeletons or add an in-code annotation on the
PreRequestHook declaration (the func PreRequestHook(ctx *schemas.BifrostContext,
req *schemas.BifrostRequest) error) stating it is optional and only available in
v1.6.x+; apply the same change to the other instance referenced (lines around
the second occurrence) and ensure the comment explicitly marks the API contract
as v1.6.x+ to prevent copy/paste confusion.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: eafa93f0-dec4-4a1c-9eab-1df87fc209ae

📥 Commits

Reviewing files that changed from the base of the PR and between fff3d21 and 4edbac5.

📒 Files selected for processing (5)
  • docs/architecture/core/plugins.mdx
  • docs/plugins/getting-started.mdx
  • docs/plugins/sequencing.mdx
  • docs/plugins/writing-go-plugin.mdx
  • docs/providers/provider-routing.mdx

Comment thread docs/architecture/core/plugins.mdx Outdated
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-docs_update_docs_for_perrequesthook branch from 4edbac5 to 9f40efe Compare June 8, 2026 06:54
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-feat_add_model_catalog_router_plugin branch from 3010c2b to 5ec0e17 Compare June 8, 2026 06:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
docs/architecture/core/plugins.mdx (1)

74-75: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

PreRequestHook error path contradicts the non-blocking error contract.

The state diagram shows PreRequestHookCall --> ShortCircuitError: Return Error, but PreRequestHook errors are non-blocking per the coding guidelines and schema definition. Errors should be logged as warnings and the pipeline should continue to the next plugin/validation stage, not short-circuit. Update the diagram to route error outcomes back into the normal flow (e.g., RouteDecided or a validation node) instead of branching to ShortCircuitError.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/architecture/core/plugins.mdx` around lines 74 - 75, The diagram
incorrectly shows PreRequestHookCall leading to ShortCircuitError; update the
flow so PreRequestHookCall error outcomes route back into the normal pipeline
(for example to RouteDecided or the validation node) instead of
ShortCircuitError, and annotate that PreRequestHook errors are non-blocking and
should be logged as warnings (per the schema/guidelines) rather than
short-circuiting the request.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@docs/architecture/core/plugins.mdx`:
- Around line 74-75: The diagram incorrectly shows PreRequestHookCall leading to
ShortCircuitError; update the flow so PreRequestHookCall error outcomes route
back into the normal pipeline (for example to RouteDecided or the validation
node) instead of ShortCircuitError, and annotate that PreRequestHook errors are
non-blocking and should be logged as warnings (per the schema/guidelines) rather
than short-circuiting the request.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 082bf81f-550f-47d0-b1e8-d9248aa8e4b0

📥 Commits

Reviewing files that changed from the base of the PR and between 4edbac5 and 9f40efe.

📒 Files selected for processing (5)
  • docs/architecture/core/plugins.mdx
  • docs/plugins/getting-started.mdx
  • docs/plugins/sequencing.mdx
  • docs/plugins/writing-go-plugin.mdx
  • docs/providers/provider-routing.mdx

@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-docs_update_docs_for_perrequesthook branch from 9f40efe to 9b1c18b Compare June 8, 2026 07:18

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
docs/plugins/writing-go-plugin.mdx (1)

281-286: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don’t present PreRequestHook as part of the v1.4.x skeleton.

This v1.4.x sample shows PreRequestHook as a standard hook, while the doc itself scopes it to v1.6.x+. In the v1.4.x tab, either remove it or mark it clearly as optional v1.6.x+ only.

Suggested edit
-// PreRequestHook is called once per top-level request (routing phase)
-// Mutations to req.Provider/req.Model/req.Fallbacks commit across fallbacks
-func PreRequestHook(ctx *schemas.BifrostContext, req *schemas.BifrostRequest) error {
-	fmt.Println("PreRequestHook called")
-	return nil
-}
+// Optional in v1.6.x+ only:
+// func PreRequestHook(ctx *schemas.BifrostContext, req *schemas.BifrostRequest) error {
+// 	fmt.Println("PreRequestHook called")
+// 	return nil
+// }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/plugins/writing-go-plugin.mdx` around lines 281 - 286, The v1.4.x
example incorrectly shows PreRequestHook as a standard hook; update the v1.4.x
skeleton to either remove the PreRequestHook function or explicitly mark it as
optional and only available in v1.6.x+ (reference symbol: PreRequestHook, types:
schemas.BifrostContext and schemas.BifrostRequest). Ensure the v1.4.x tab
content and any surrounding text clearly state that PreRequestHook is a v1.6.x+
feature so readers won’t assume it exists in v1.4.x.

Source: Coding guidelines

docs/plugins/getting-started.mdx (1)

87-87: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clarify hook lifecycle wording at this step.

Line 87 currently implies PreRequestHook, PreLLMHook, and PostLLMHook all run “for each request,” which conflicts with the per-attempt semantics documented below. Make this line explicit: PreRequestHook runs once per top-level request; PreLLMHook/PostLLMHook run per provider attempt (including fallbacks).

Suggested edit
-3. **Hook Execution** - Calls `PreRequestHook()`, `PreLLMHook()` and `PostLLMHook()` for each request
+3. **Hook Execution** - Calls `PreRequestHook()` once per top-level request, then `PreLLMHook()`/`PostLLMHook()` per provider attempt (including fallbacks)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/plugins/getting-started.mdx` at line 87, Update the wording in the list
item so it explicitly distinguishes hook lifecycles: state that PreRequestHook()
is invoked once per top-level request, while PreLLMHook() and PostLLMHook() are
invoked for each provider attempt (including fallbacks), and replace the phrase
"for each request" with this clarified sentence referencing PreRequestHook,
PreLLMHook, and PostLLMHook.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@docs/plugins/getting-started.mdx`:
- Line 87: Update the wording in the list item so it explicitly distinguishes
hook lifecycles: state that PreRequestHook() is invoked once per top-level
request, while PreLLMHook() and PostLLMHook() are invoked for each provider
attempt (including fallbacks), and replace the phrase "for each request" with
this clarified sentence referencing PreRequestHook, PreLLMHook, and PostLLMHook.

In `@docs/plugins/writing-go-plugin.mdx`:
- Around line 281-286: The v1.4.x example incorrectly shows PreRequestHook as a
standard hook; update the v1.4.x skeleton to either remove the PreRequestHook
function or explicitly mark it as optional and only available in v1.6.x+
(reference symbol: PreRequestHook, types: schemas.BifrostContext and
schemas.BifrostRequest). Ensure the v1.4.x tab content and any surrounding text
clearly state that PreRequestHook is a v1.6.x+ feature so readers won’t assume
it exists in v1.4.x.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: fad54266-27f0-40fb-b46e-46d5d34a8512

📥 Commits

Reviewing files that changed from the base of the PR and between 9f40efe and 9b1c18b.

📒 Files selected for processing (5)
  • docs/architecture/core/plugins.mdx
  • docs/plugins/getting-started.mdx
  • docs/plugins/sequencing.mdx
  • docs/plugins/writing-go-plugin.mdx
  • docs/providers/provider-routing.mdx

@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-feat_add_model_catalog_router_plugin branch from 5ec0e17 to 13daf7a Compare June 8, 2026 11:55
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-docs_update_docs_for_perrequesthook branch 2 times, most recently from 0404470 to 252041c Compare June 8, 2026 12:24
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-feat_add_model_catalog_router_plugin branch from 13daf7a to 24abc35 Compare June 8, 2026 12:24
@Madhuvod
Madhuvod force-pushed the 06-01-feat_add_model_catalog_router_plugin branch from 24abc35 to 13daf7a Compare June 8, 2026 12:25
@Madhuvod
Madhuvod force-pushed the 06-01-docs_update_docs_for_perrequesthook branch from 252041c to 0404470 Compare June 8, 2026 12:25
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-feat_add_model_catalog_router_plugin branch from 13daf7a to d803fb5 Compare June 8, 2026 12:28
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-01-docs_update_docs_for_perrequesthook branch from 0404470 to 2aef19b Compare June 8, 2026 12:28

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
docs/plugins/getting-started.mdx (1)

87-87: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix lifecycle step wording to avoid semantic contradiction.

Line 87 currently says all three hooks run “for each request,” but PreLLMHook()/PostLLMHook() are per-attempt (including fallbacks), while PreRequestHook() is once per top-level request.

Suggested edit
-3. **Hook Execution** - Calls `PreRequestHook()`, `PreLLMHook()` and `PostLLMHook()` for each request
+3. **Hook Execution** - Calls `PreRequestHook()` once per top-level request, then `PreLLMHook()`/`PostLLMHook()` for each provider attempt (including fallbacks)

As per coding guidelines, PreRequestHook is once-per-request, while PreLLMHook/PostLLMHook execute per-attempt and re-run on fallbacks.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/plugins/getting-started.mdx` at line 87, Update the lifecycle step
wording to remove the contradictory "for each request" phrase: state that
PreRequestHook() runs once per top-level request, while PreLLMHook() and
PostLLMHook() run per attempt (and will re-run on fallbacks); edit the sentence
referencing PreRequestHook, PreLLMHook, and PostLLMHook to reflect this exact
distinction so readers know which hooks are once-per-request versus per-attempt.

Sources: Coding guidelines, Learnings

docs/plugins/writing-go-plugin.mdx (1)

155-163: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Clarify that these stubs are v1.6.x+ only (don’t present as active v1.5/v1.4 hooks).

These two skeleton tabs currently present PreRequestHook as if it applies to v1.5.x+/v1.4.x directly, which conflicts with the versioned hook contract and can mislead implementers.

Suggested edit
-// PreRequestHook is called once per top-level request (NOT per fallback attempt).
-// This is the routing phase — use it for provider/model/fallback decisions.
-// Mutations to req.Provider/req.Model/req.Fallbacks commit and propagate to every attempt.
-// Errors are non-blocking (logged + skipped).
-func PreRequestHook(ctx *schemas.BifrostContext, req *schemas.BifrostRequest) error {
-	ctx.Log(schemas.LogLevelInfo, "PreRequestHook called")
-	// Plugins that don't participate in routing should just return nil
-	return nil
-}
+// Optional in v1.6.x+ only:
+// func PreRequestHook(ctx *schemas.BifrostContext, req *schemas.BifrostRequest) error {
+// 	ctx.Log(schemas.LogLevelInfo, "PreRequestHook called")
+// 	return nil
+// }
-// PreRequestHook is called once per top-level request (routing phase)
-// Mutations to req.Provider/req.Model/req.Fallbacks commit across fallbacks
-func PreRequestHook(ctx *schemas.BifrostContext, req *schemas.BifrostRequest) error {
-	fmt.Println("PreRequestHook called")
-	return nil
-}
+// Optional in v1.6.x+ only:
+// func PreRequestHook(ctx *schemas.BifrostContext, req *schemas.BifrostRequest) error {
+// 	fmt.Println("PreRequestHook called")
+// 	return nil
+// }

As per coding guidelines, “PreRequestHook added for v1.6.x+; older versions use the prior hook set.”

Also applies to: 281-286

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/plugins/writing-go-plugin.mdx` around lines 155 - 163, Update the
PreRequestHook stub to explicitly state it is available only in v1.6.x and
later: annotate the comment above the function to say "PreRequestHook (v1.6.x+)"
and add a short note that older versions (v1.5.x/v1.4.x) use the prior hook set;
make the same change for the other skeleton at lines referenced, ensuring the
comment near the function signature for PreRequestHook (and parameters
schemas.BifrostContext, schemas.BifrostRequest) clearly indicates the version
constraint so implementers aren’t misled.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@docs/plugins/getting-started.mdx`:
- Line 87: Update the lifecycle step wording to remove the contradictory "for
each request" phrase: state that PreRequestHook() runs once per top-level
request, while PreLLMHook() and PostLLMHook() run per attempt (and will re-run
on fallbacks); edit the sentence referencing PreRequestHook, PreLLMHook, and
PostLLMHook to reflect this exact distinction so readers know which hooks are
once-per-request versus per-attempt.

In `@docs/plugins/writing-go-plugin.mdx`:
- Around line 155-163: Update the PreRequestHook stub to explicitly state it is
available only in v1.6.x and later: annotate the comment above the function to
say "PreRequestHook (v1.6.x+)" and add a short note that older versions
(v1.5.x/v1.4.x) use the prior hook set; make the same change for the other
skeleton at lines referenced, ensuring the comment near the function signature
for PreRequestHook (and parameters schemas.BifrostContext,
schemas.BifrostRequest) clearly indicates the version constraint so implementers
aren’t misled.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4d5e7d85-3261-496c-b708-35a9edbcaac5

📥 Commits

Reviewing files that changed from the base of the PR and between 9b1c18b and 0404470.

📒 Files selected for processing (5)
  • docs/architecture/core/plugins.mdx
  • docs/plugins/getting-started.mdx
  • docs/plugins/sequencing.mdx
  • docs/plugins/writing-go-plugin.mdx
  • docs/providers/provider-routing.mdx

akshaydeo commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • Jun 9, 5:17 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 9, 5:21 AM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo changed the base branch from 06-01-feat_add_model_catalog_router_plugin to graphite-base/3935 June 9, 2026 05:19
@akshaydeo
akshaydeo changed the base branch from graphite-base/3935 to dev June 9, 2026 05:19
@akshaydeo
akshaydeo merged commit 7d50a70 into dev Jun 9, 2026
9 checks passed
@akshaydeo
akshaydeo deleted the 06-01-docs_update_docs_for_perrequesthook branch June 9, 2026 05:21
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.

3 participants