Skip to content

feat: Add custom path suffix support for Custom Providers#1195

Open
Yu-Xiao-Sheng wants to merge 13 commits intomnfst:mainfrom
Yu-Xiao-Sheng:feature/custom-provider-path-suffix
Open

feat: Add custom path suffix support for Custom Providers#1195
Yu-Xiao-Sheng wants to merge 13 commits intomnfst:mainfrom
Yu-Xiao-Sheng:feature/custom-provider-path-suffix

Conversation

@Yu-Xiao-Sheng
Copy link
Copy Markdown

@Yu-Xiao-Sheng Yu-Xiao-Sheng commented Mar 18, 2026

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.


Summary by cubic

Adds custom path suffix support for Custom Providers and per‑agent request timeouts. Keeps the default /v1/chat/completions and uses agent-specific timeouts when forwarding to providers.

  • New Features
    • Custom Providers: add nullable path_suffix to entity/DTOs/controller responses and proxy; buildCustomEndpoint accepts pathSuffix and normalizes a leading slash; defaults to /v1/chat/completions when null for backwards compatibility.
    • Frontend: add path_suffix input to the Custom Provider form; update CustomProviderData, createCustomProvider, and updateCustomProvider to handle it.
    • Agent timeouts: add request_timeout_ms to Agent (with migration); extend rename endpoint/DTO to accept it; include in analytics responses; ProxyService reads the agent timeout and passes it to ProviderClient.forward, which now supports a custom timeout; default remains 180s.
    • Settings UI: add “Request timeout (seconds)” field; renameAgent API sends request_timeout_ms; empty uses the default; input validated (min 10s, max 3600s).

Written for commit 1ba0af4. Summary will update on new commits.

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.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

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-ai with guidance or docs links (including llms.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.

Comment thread packages/backend/src/routing/proxy/provider-endpoints.ts Outdated
- 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
@Yu-Xiao-Sheng
Copy link
Copy Markdown
Author

1 issue found across 3 files
Prompt for AI agents (unresolved issues)

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-ai` with guidance or docs links (including `llms.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.

Thanks @cubic-dev-ai for the review! I've fixed the P1 backwards compatibility
issue.

Fix: Restored the default path to /v1/chat/completions (using
openaiPath) when path_suffix is null. This ensures existing custom
providers continue to work as before.

For GLM Coding Plan users: They should explicitly set path_suffix = '/chat/completions' to use the correct endpoint (without /v1).

The updated code now:

  • Uses openaiPath (which is /v1/chat/completions) when path_suffix is
    null - preserving backwards compatibility
  • Allows providers like GLM Coding Plan to override by setting path_suffix = '/chat/completions'

- 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
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.01%. Comparing base (fa074ca) to head (1ba0af4).
⚠️ Report is 57 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            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              
Flag Coverage Δ
frontend ?
plugin 96.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brunobuddy
Copy link
Copy Markdown
Member

@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

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.

2 participants