docs for complexity router and openapi reference#3716
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a Complexity Router docs page and navigation entry; defines ChangesComplexity Router Feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ee75787 to
032bc77
Compare
Confidence Score: 5/5Safe to merge; all doc content and API paths cross-check against the live handler and schema implementations, and the one code change (comment fix) is purely cosmetic. The changes are documentation and OpenAPI spec additions. API paths, schema field names, tier boundaries, and fallback behaviour in the docs all match what the Go handlers and config schema actually implement. The only non-doc touch is a comment correction in a TypeScript types file, which is correct given how the UI base URL is constructed. ui/public/images/prisma_airs.png — appears to be an accidentally included image not referenced anywhere in the UI. Important Files Changed
Reviews (22): Last reviewed commit: "docs for complexity router and openapi r..." | Re-trigger Greptile |
032bc77 to
96b8aad
Compare
d56b305 to
5cc4920
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
docs/openapi/schemas/management/governance.yaml (1)
1318-1341: 💤 Low valueDocument that ordering constraint is runtime-validated, not schema-enforced.
The description states "All values must satisfy 0 < simple_medium < medium_complex < complex_reasoning < 1", but JSON Schema cannot enforce cross-field ordering (only per-field bounds via
exclusiveMinimum/exclusiveMaximum). The ordering constraint must be validated by the API handler at runtime and will produce a400 BadRequeston violation.Consider adding a note in the description that ordering validation happens at the API layer (as documented in the PUT operation at line 1090), so clients understand that schema-valid payloads may still be rejected.
📝 Suggested clarification
ComplexityTierBoundaries: type: object - description: Score thresholds for complexity tier classification. All values must satisfy 0 < simple_medium < medium_complex < complex_reasoning < 1. + description: | + Score thresholds for complexity tier classification. All values must satisfy + 0 < simple_medium < medium_complex < complex_reasoning < 1. + Note: Cross-field ordering is validated at runtime by the API; the schema enforces only per-field bounds. additionalProperties: false🤖 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/openapi/schemas/management/governance.yaml` around lines 1318 - 1341, Update the ComplexityTierBoundaries schema description to explicitly state that cross-field ordering (0 < simple_medium < medium_complex < complex_reasoning < 1) is NOT enforced by the JSON Schema and is validated at the API layer (runtime) — violations will result in a 400 BadRequest; reference the PUT operation's runtime validation behavior and ensure the description mentions clients may pass schema-valid payloads that are still rejected if ordering is invalid.
🤖 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/openapi/openapi.json`:
- Around line 40364-40391: The OpenAPI schema's tier_boundaries (properties
simple_medium, medium_complex, complex_reasoning) notes a required ordering (0 <
simple_medium < medium_complex < complex_reasoning < 1) that JSON Schema cannot
enforce at runtime; add validation in the request handling code that inspects
tier_boundaries and verifies simple_medium < medium_complex < complex_reasoning
(and each is between 0 and 1), and if the check fails return a 400 response with
a clear error message indicating which boundary comparison failed (e.g.,
"simple_medium must be less than medium_complex").
- Around line 48995-49003: The new response component ConfigStoreUnavailable is
defined but unused; update the three complexity-analyzer-config endpoints (the
GET, PUT, and POST operations that currently inline identical 503 responses) to
reference the component instead of duplicating the schema by replacing their
inline 503 response bodies with "$ref":
"`#/components/responses/ConfigStoreUnavailable`"; alternatively, if the component
is not needed, remove the ConfigStoreUnavailable component declaration to avoid
dead OpenAPI definitions. Ensure the change is applied to the operations named
for complexity-analyzer-config (GET complexity-analyzer-config, PUT
complexity-analyzer-config, POST complexity-analyzer-config) so they all
consistently reference the shared response component.
---
Nitpick comments:
In `@docs/openapi/schemas/management/governance.yaml`:
- Around line 1318-1341: Update the ComplexityTierBoundaries schema description
to explicitly state that cross-field ordering (0 < simple_medium <
medium_complex < complex_reasoning < 1) is NOT enforced by the JSON Schema and
is validated at the API layer (runtime) — violations will result in a 400
BadRequest; reference the PUT operation's runtime validation behavior and ensure
the description mentions clients may pass schema-valid payloads that are still
rejected if ordering is invalid.
🪄 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: 1e90ca74-44a5-482c-b6f8-655b6bbede83
⛔ Files ignored due to path filters (6)
docs/media/architecture-complexity-router.pngis excluded by!**/*.pngdocs/media/complexity-logic-architecture.pngis excluded by!**/*.pngdocs/media/ui-complexity-router-config.pngis excluded by!**/*.pngdocs/media/ui-complexity-router-keywords.pngis excluded by!**/*.pngdocs/media/ui-routing-logs-complexity.pngis excluded by!**/*.pngdocs/media/ui-routing-rule-complexity.pngis excluded by!**/*.png
📒 Files selected for processing (10)
docs/docs.jsondocs/features/governance/complexity-router.mdxdocs/features/governance/routing.mdxdocs/openapi/openapi.jsondocs/openapi/openapi.yamldocs/openapi/paths/management/governance.yamldocs/openapi/schemas/management/governance.yamldocs/providers/provider-routing.mdxdocs/providers/routing-rules.mdxui/lib/types/complexityRouter.ts
✅ Files skipped from review due to trivial changes (2)
- docs/providers/provider-routing.mdx
- ui/lib/types/complexityRouter.ts
5cc4920 to
3a08ff0
Compare
654ce74 to
20c9b3f
Compare
3a08ff0 to
3d09d45
Compare
20c9b3f to
f49fb9b
Compare
b66e714 to
7f1d0df
Compare
f49fb9b to
6c5e5b0
Compare
6c5e5b0 to
d28667a
Compare
7f1d0df to
5b4a4bd
Compare
5b4a4bd to
dfd376e
Compare
d2741d2 to
e7f5826
Compare
c13d822 to
9ffc142
Compare
794b85a to
ccb6b3a
Compare
9ffc142 to
0bae999
Compare
ccb6b3a to
4351e01
Compare
0bae999 to
3b8e6cd
Compare
4351e01 to
3966859
Compare
3966859 to
6601d0a
Compare
3b8e6cd to
89303f9
Compare
89303f9 to
1d1c7e7
Compare
6601d0a to
acd1741
Compare
1d1c7e7 to
a149544
Compare
2cfba2a to
f6f934f
Compare
a149544 to
887b9fc
Compare
f6f934f to
dc7e360
Compare
0f24388 to
c1f0650
Compare
dc7e360 to
4d64c2c
Compare
Merge activity
|
The base branch was changed.
4d64c2c to
ddf4862
Compare
## Summary Adds documentation and OpenAPI spec coverage for the Complexity Router feature, which automatically classifies incoming LLM requests into four tiers (SIMPLE, MEDIUM, COMPLEX, REASONING) and exposes a `complexity_tier` CEL variable for use in routing rules. This allows requests to be steered to appropriately-sized models based on prompt content with no application-side changes. ## Changes - Added `docs/features/governance/complexity-router.mdx` — full reference page covering the scoring algorithm (five weighted dimensions, system prompt contribution, conversation context blending, output complexity floor, reasoning override), tier classification boundaries, configuration via UI/API/config.json, CEL routing examples, observability, and troubleshooting guidance. - Registered the new page in `docs/docs.json` under the Governance section. - Added cross-reference callouts in `routing.mdx`, `routing-rules.mdx`, and `provider-routing.mdx` pointing to the Complexity Router page and describing the `complexity_tier` variable. - Added `GET /api/governance/complexity-analyzer-config`, `PUT /api/governance/complexity-analyzer-config`, and `POST /api/governance/complexity-analyzer-config/reset` endpoints to the OpenAPI spec (both `openapi.json` and `openapi.yaml`), with `ComplexityAnalyzerConfig`, `ComplexityTierBoundaries`, and `ComplexityKeywordConfig` schemas. - Added a `ConfigStoreUnavailable` (503) reusable response component to the OpenAPI spec. - Corrected the API path reference in `ui/lib/types/complexityRouter.ts` from `/api/governance/complexity` to `/governance/complexity-analyzer-config`. - Added supporting architecture and UI screenshot assets under `docs/media/`. ## Type of change - [ ] Bug fix - [ ] Feature - [ ] Refactor - [x] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [x] UI (React) - [x] Docs ## How to test 1. Navigate to the docs site and confirm the **Complexity Router** page appears under the Governance section in the sidebar. 2. Verify all internal links (Routing Rules, Virtual Keys, Budget & Limits, Provider Routing) resolve correctly. 3. Confirm the OpenAPI spec renders the three new `/api/governance/complexity-analyzer-config` endpoints with correct request/response schemas. 4. Validate the `complexity_tier` CEL variable examples in `routing-rules.mdx` are consistent with the behavior described in the Complexity Router page. ## Breaking changes - [ ] Yes - [x] No ## Related issues N/A ## Security considerations No new auth surfaces or secrets handling introduced. The API endpoints follow the same governance authentication patterns as existing endpoints. ## Checklist - [x] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [x] I updated documentation where needed - [x] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Introduced Complexity Router feature to classify requests into four tiers (SIMPLE, MEDIUM, COMPLEX, REASONING) for dynamic request routing. * Added REST API endpoints to retrieve, update, and reset complexity analyzer configuration at runtime. * **Documentation** * Added comprehensive guide for Complexity Router feature and configuration options. * Updated routing documentation to reference Complexity Router and explain the `complexity_tier` routing variable. * Clarified static vs. dynamic routing capabilities. <!-- end of auto-generated comment: release notes by coderabbit.ai -->

Summary
Adds documentation and OpenAPI spec coverage for the Complexity Router feature, which automatically classifies incoming LLM requests into four tiers (SIMPLE, MEDIUM, COMPLEX, REASONING) and exposes a
complexity_tierCEL variable for use in routing rules. This allows requests to be steered to appropriately-sized models based on prompt content with no application-side changes.Changes
docs/features/governance/complexity-router.mdx— full reference page covering the scoring algorithm (five weighted dimensions, system prompt contribution, conversation context blending, output complexity floor, reasoning override), tier classification boundaries, configuration via UI/API/config.json, CEL routing examples, observability, and troubleshooting guidance.docs/docs.jsonunder the Governance section.routing.mdx,routing-rules.mdx, andprovider-routing.mdxpointing to the Complexity Router page and describing thecomplexity_tiervariable.GET /api/governance/complexity-analyzer-config,PUT /api/governance/complexity-analyzer-config, andPOST /api/governance/complexity-analyzer-config/resetendpoints to the OpenAPI spec (bothopenapi.jsonandopenapi.yaml), withComplexityAnalyzerConfig,ComplexityTierBoundaries, andComplexityKeywordConfigschemas.ConfigStoreUnavailable(503) reusable response component to the OpenAPI spec.ui/lib/types/complexityRouter.tsfrom/api/governance/complexityto/governance/complexity-analyzer-config.docs/media/.Type of change
Affected areas
How to test
/api/governance/complexity-analyzer-configendpoints with correct request/response schemas.complexity_tierCEL variable examples inrouting-rules.mdxare consistent with the behavior described in the Complexity Router page.Breaking changes
Related issues
N/A
Security considerations
No new auth surfaces or secrets handling introduced. The API endpoints follow the same governance authentication patterns as existing endpoints.
Checklist
docs/contributing/README.mdand followed the guidelinesSummary by CodeRabbit
New Features
Documentation
complexity_tierrouting variable.