feat: Add custom path suffix support for Custom Providers#1195
feat: Add custom path suffix support for Custom Providers#1195Yu-Xiao-Sheng wants to merge 13 commits intomnfst:mainfrom
Conversation
This change allows Custom Providers to specify a custom path suffix instead of hardcoding /v1/chat/completions, which was causing issues with providers like GLM Coding Plan that use different URL structures. Changes: - Added path_suffix column to CustomProvider entity (nullable, defaults to null) - Modified buildCustomEndpoint to accept optional pathSuffix parameter - Updated default path from /v1/chat/completions to /chat/completions - Updated proxy.service.ts to pass path_suffix when building custom endpoint This enables GLM Coding Plan and other providers with non-standard URL structures to work correctly without requiring hardcoded provider configurations.
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/backend/src/routing/proxy/provider-endpoints.ts">
<violation number="1" location="packages/backend/src/routing/proxy/provider-endpoints.ts:144">
P1: The new default custom-provider path (`/chat/completions`) breaks existing providers that relied on the previous `/v1/chat/completions` behavior when `path_suffix` is null.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- Restore default path to /v1/chat/completions when path_suffix is null - This fixes breaking change introduced in previous commit - Custom providers can still use custom paths by setting path_suffix - GLM Coding Plan users should set path_suffix to "/chat/completions" Fixes cubic-dev-ai review comment P1
Thanks @cubic-dev-ai for the review! I've fixed the P1 backwards compatibility Fix: Restored the default path to For GLM Coding Plan users: They should explicitly set The updated code now:
|
- Add path_suffix to CustomProviderData interface - Add path_suffix input field in CustomProviderForm - Update createCustomProvider and updateCustomProvider to accept path_suffix - Defaults to null (uses /v1/chat/completions)
- Add path_suffix field to CreateCustomProviderDto and UpdateCustomProviderDto - Ensure copy-assets.js is run before packaging - This allows API to accept and return path_suffix field
- Add path_suffix field to all custom provider API responses - Update list, create, and update methods to include path_suffix
Features: 1. Configurable request timeout per agent - Add request_timeout_ms field to Agent entity - Add migration 1773600000000-AddAgentRequestTimeout - ProxyService reads agent-specific timeout or uses default 180s - ProviderClient.forward accepts optional timeoutMs parameter 2. Fix SPA refresh 404 issue - Add App controller with wildcard route handler - Returns index.html for unmatched routes (except API/assets) - Allows browser refresh on /agents/local-agent to work correctly
Add explicit routes for /agents/:agentName to ensure they're handled before wildcard. This fixes the 404 issue when refreshing the browser on agent-specific routes.
Replace controller-based approach with middleware to ensure SPA fallback works correctly for all routes including /agents/local-agent. Middleware is applied to all routes except API endpoints.
Use the same path resolution as ServeStaticModule to ensure the middleware can find index.html correctly.
- Add request_timeout_ms field to getAgents API response - Add timeout input in Settings General tab - Update renameAgent API to accept request_timeout_ms - Users can now configure timeout in seconds (min 10s, max 3600s) - Empty value uses default 180 seconds (3 minutes)
Remove the SpaFallbackMiddleware that was causing root path (/) to return 404. The middleware approach conflicts with ServeStaticModule. Frontend routing issue needs a different solution (e.g. nginx config). The core timeout configuration feature is unaffected.
The @get('/') route in AppController was taking precedence over ServeStaticModule, preventing it from serving index.html at the root path. Removing AppController allows ServeStaticModule to work correctly.
Add request timeout configuration feature: - Agent-level configurable request timeout (request_timeout_ms field) - Frontend UI in Settings page to configure timeout in seconds - Backend uses configured timeout or defaults to 180 seconds (3 minutes) - Fix root path 404 issue by removing conflicting AppController This merge combines both path_suffix support and timeout configuration into a single PR.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1195 +/- ##
==========================================
- Coverage 98.54% 96.01% -2.53%
==========================================
Files 93 13 -80
Lines 7359 678 -6681
Branches 2819 192 -2627
==========================================
- Hits 7252 651 -6601
+ Misses 80 0 -80
Partials 27 27
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
@Yu-Xiao-Sheng that is a massive PR that is not fixing any issue on GitHub. Please create the issue you are solving first and then attach the PR to it |
This change allows Custom Providers to specify a custom path suffix instead of hardcoding /v1/chat/completions, which was causing issues with providers like GLM Coding Plan that use different URL structures.
Changes:
This enables GLM Coding Plan and other providers with non-standard URL structures to work correctly without requiring hardcoded provider configurations.
Summary by cubic
Adds custom path suffix support for Custom Providers and per‑agent request timeouts. Keeps the default
/v1/chat/completionsand uses agent-specific timeouts when forwarding to providers.path_suffixto entity/DTOs/controller responses and proxy;buildCustomEndpointacceptspathSuffixand normalizes a leading slash; defaults to/v1/chat/completionswhen null for backwards compatibility.path_suffixinput to the Custom Provider form; updateCustomProviderData,createCustomProvider, andupdateCustomProviderto handle it.request_timeout_msto Agent (with migration); extend rename endpoint/DTO to accept it; include in analytics responses;ProxyServicereads the agent timeout and passes it toProviderClient.forward, which now supports a custom timeout; default remains 180s.renameAgentAPI sendsrequest_timeout_ms; empty uses the default; input validated (min 10s, max 3600s).Written for commit 1ba0af4. Summary will update on new commits.