Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 6, 2025

This PR attempts to address Issue #9879. Feedback and guidance are welcome.

Problem

The Z.ai provider currently only shows coding plan endpoints but not the regular API endpoints. Users who are using API billing need access to the standard API endpoints.

Solution

Added two new API line options to support regular API billing:

Changes

  • Added new API line options to zaiApiLineSchema in packages/types/src/provider-settings.ts
  • Added corresponding endpoint configurations to zaiApiLineConfigs in packages/types/src/providers/zai.ts
  • Updated display names to distinguish between "Coding" and "API" endpoints for clarity
  • Added comprehensive tests for the new API endpoints in src/api/providers/__tests__/zai.spec.ts

Testing

  • All existing tests pass
  • Added new test cases for both international_api and china_api endpoints
  • Verified correct base URLs are used for each endpoint
  • Confirmed proper model selection based on region

Fixes #9879


Important

Add international_api and china_api endpoints for Z.ai provider with tests and configuration updates.

  • Behavior:
    • Added international_api and china_api endpoints to zaiApiLineSchema in provider-settings.ts.
    • Updated zaiApiLineConfigs in zai.ts with new endpoint configurations.
    • Updated display names for clarity between "Coding" and "API" endpoints.
  • Testing:
    • Added tests for international_api and china_api in zai.spec.ts.
    • Verified correct base URLs and API key usage for new endpoints.
    • Confirmed model selection and configuration for both new endpoints.
  • Misc:
    • All existing tests pass.

This description was created by Ellipsis for ab9d34f. You can customize this summary. It will automatically update as commits are pushed.

- Add international_api and china_api options to zaiApiLineSchema
- Add corresponding endpoint configurations to zaiApiLineConfigs
- Update display names to distinguish between Coding and API endpoints
- Add comprehensive tests for new API endpoints

Fixes #9879
@roomote
Copy link
Contributor Author

roomote bot commented Dec 6, 2025

Rooviewer Clock   See task on Roo Cloud

Review completed. Found 1 issue that needs attention:

  • Verify China API endpoint URL - the issue specifies pass but implementation uses paas

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 6, 2025
@richtong
Copy link

richtong commented Dec 7, 2025

Ye that's correct a typo in original issue. Fixed. Should be paas

@mrubens
Copy link
Collaborator

mrubens commented Dec 7, 2025

@hannesrudolph @richtong looks like we removed the other two endpoints here, but I can't remember why: #8693.

@richtong just to confirm - you have an API key that works with the regular endpoint and not the coding endpoint?

@hannesrudolph
Copy link
Collaborator

@hannesrudolph @richtong looks like we removed the other two endpoints here, but I can't remember why: #8693.

@richtong just to confirm - you have an API key that works with the regular endpoint and not the coding endpoint?

They told us to as they would manage the switching at their end

@richtong
Copy link

richtong commented Dec 7, 2025 via email

@richtong
Copy link

richtong commented Dec 7, 2025 via email

@richtong
Copy link

richtong commented Dec 9, 2025

@hannesrudolph @richtong looks like we removed the other two endpoints here, but I can't remember why: #8693.

@richtong just to confirm - you have an API key that works with the regular endpoint and not the coding endpoint?

Yes that's correct, we an API key that only works with regular endpoints and not the coding endpoints, so be nice to allow those urls as well :-)

@richtong
Copy link

@mrubens yes just confirmed we need the api end point with z.ai

@hannesrudolph @richtong looks like we removed the other two endpoints here, but I can't remember why: #8693.

@richtong just to confirm - you have an API key that works with the regular endpoint and not the coding endpoint?

@roomote
Copy link
Contributor Author

roomote bot commented Dec 10, 2025

Hi @mrubens and @hannesrudolph,

Based on the discussion, it appears that:

  1. The user (@richtong) has confirmed they need the regular API endpoints - They have an API key that only works with the regular endpoints (not the coding endpoints)
  2. The Z.ai documentation confirms this distinction - Per their docs at https://docs.z.ai/guides/develop/http/introduction, they specify:
    • General API endpoint: https://api.z.ai/api/paas/v4/
    • Coding endpoint: https://api.z.ai/api/coding/paas/v4/ (only for Coding Plan users)
  3. The user gets rate limit errors when trying to use their API key with the coding endpoint

While PR #8693 previously removed these endpoints based on Z.ai's indication they would handle switching at their end, it seems this hasn't been implemented yet, and users with API-only accounts still need access to the regular endpoints.

This PR adds back the regular API endpoints to support users with API billing accounts. All tests are passing and the implementation looks good.

Could we get this reviewed for approval? This would unblock users who have API-only accounts with Z.ai.

cc: @richtong

@hannesrudolph hannesrudolph moved this from Triage to PR [Needs Review] in Roo Code Roadmap Dec 11, 2025
@hannesrudolph hannesrudolph marked this pull request as ready for review December 11, 2025 06:51
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Dec 11, 2025
@roomote
Copy link
Contributor Author

roomote bot commented Dec 11, 2025

Rooviewer Clock   See task on Roo Cloud

Review completed. No issues found.

The previous concern about paas vs pass in the URL has been resolved - @richtong confirmed that paas (Platform as a Service) is the correct path per Z.ai documentation.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Copy link
Collaborator

@hannesrudolph hannesrudolph left a comment

Choose a reason for hiding this comment

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

Code Review Needed

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 11, 2025
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Dec 11, 2025
mini2s added a commit to zgsm-ai/costrict that referenced this pull request Dec 11, 2025
* fix: restore content undefined check in WriteToFileTool.handlePartial() (RooCodeInc#9614)

* fix: exclude access_mcp_resource tool when MCP has no resources (RooCodeInc#9615)

* fix: prevent model cache from persisting empty API responses (RooCodeInc#9623)

* fix: update default settings for inline terminal and codebase indexing (RooCodeInc#9622)

Co-authored-by: Roo Code <[email protected]>

* feat(mistral): add native tool calling support (RooCodeInc#9625)

* feat: wire MULTIPLE_NATIVE_TOOL_CALLS experiment to OpenAI parallel_tool_calls (RooCodeInc#9621)

* feat(bedrock): allow global inference selection when cross-region is enabled (RooCodeInc#9616)

Co-authored-by: Roo Code <[email protected]>

* fix: defer new_task tool_result until subtask completes for native protocol (RooCodeInc#9628)

* fix: convert line_ranges strings to lineRanges objects in native tool calls (RooCodeInc#9627)

* fix: filter non-Anthropic content blocks before sending to Vertex API (RooCodeInc#9618)

* Add fine grained tool streaming for OpenRouter Anthropic (RooCodeInc#9629)

* Release v3.34.6 (RooCodeInc#9631)

* Changeset version bump (RooCodeInc#9632)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* fix: OpenRouter GPT-5 strict schema validation for read_file tool (RooCodeInc#9633)

* fix: create parent directories early in write_to_file to prevent ENOENT errors (RooCodeInc#9640)

* Fix openrouter tool calls (RooCodeInc#9642)

* fix(claude-code): disable native tools and temperature support (RooCodeInc#9643)

* Enable native tool calling for z.ai (RooCodeInc#9645)

* Moonshot native tool call support (RooCodeInc#9646)

* Support native tools in the anthropic provider (RooCodeInc#9644)

Co-authored-by: Roo Code <[email protected]>

* Add 'taking you to cloud' screen after provider welcome (RooCodeInc#9652)

* chore: add changeset for v3.34.7 (RooCodeInc#9651)

* Changeset version bump (RooCodeInc#9654)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* fix: race condition in new_task tool for native protocol (RooCodeInc#9655)

The pendingNewTaskToolCallId was being set AFTER startSubtask() returned.
However, startSubtask() contains a 500ms delay during which the subtask
could complete. If the subtask completed during this window, completeSubtask()
would be called before pendingNewTaskToolCallId was set, causing it to
fall through to the XML protocol path and add a text message instead of
a proper tool_result block, breaking the API conversation structure.

This fix moves the pendingNewTaskToolCallId assignment to happen BEFORE
calling startSubtask(), ensuring the ID is set before the subtask starts.
If the subtask creation fails, the pending ID is cleared.

* chore: add changeset for v3.34.8 (RooCodeInc#9657)

* Changeset version bump (RooCodeInc#9658)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* feat: add model-specific tool customization via excludedTools and includedTools (RooCodeInc#9641)

* feat: add model-specific tool customization via excludedTools and includedTools

- Add excludedTools and includedTools to ModelInfo schema
- Implement applyModelToolCustomization helper to filter tools based on model config
- Integrate model tool filtering into filterNativeToolsForMode for native protocol
- Add comprehensive tests for tool customization functionality
- Wire up modelInfo through buildNativeToolsArray and Task.ts

This allows providers to override which native tools are available on a per-model basis via MODEL_DEFAULTS, enabling better control over tool selection for models with specific needs.

* feat: add customTools for opt-in only tools

- Add customTools array to ToolGroupConfig for defining opt-in only tools
- Update getToolsForMode() to exclude customTools from default tool set
- Modify applyModelToolCustomization() to include customTools only via includedTools
- Add tests for customTools functionality
- Add comprehensive documentation with usage examples

customTools allows defining tools that are NOT available by default,
even when a mode includes their group. These tools are only available
when explicitly included via a model's includedTools configuration.

This enables:
- Gradual rollout of experimental tools
- Model-specific specialized capabilities
- Safe experimentation without affecting default tool sets

* Add assertions for customTools tests per review feedback

* test: add tests for including customTools via includedTools

* Update src/core/prompts/tools/__tests__/filter-tools-for-mode.spec.ts

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* feat(web-evals): add task log viewing, export failed logs, and new run options (RooCodeInc#9637)

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>

* Metadata‑driven subtasks (no UI changes): automatic parent resume and single‑open safety (RooCodeInc#9090)

* feat: add search_and_replace tool for batch text replacements (RooCodeInc#9549)

Co-authored-by: daniel-lxs <[email protected]>

* feat: enable native tool support for DeepSeek and Doubao models (RooCodeInc#9671)

Add supportsNativeTools: true to DeepSeek and Doubao model definitions,
enabling native OpenAI-compatible tool calling for these providers.

Both providers already extend OpenAiHandler which has built-in support
for native tools, so this change is all that's needed to enable the feature.

* feat: add native tool support to Requesty provider (RooCodeInc#9672)

- Import resolveToolProtocol and TOOL_PROTOCOL from @roo-code/types
- Add tools and tool_choice to completion params when native protocol is enabled
- Handle tool_call_partial chunks in streaming response
- Add comprehensive tests for native tool support

* Include tool format in environment details (RooCodeInc#9661)

* feat(groq): enable native tool support for models that support function calling (RooCodeInc#9673)

Co-authored-by: Matt Rubens <[email protected]>

* feat: add native tools support for OpenAI-compatible providers (RooCodeInc#9676)

Co-authored-by: Matt Rubens <[email protected]>

* feat: enable native tool calls for Vertex Gemini models (RooCodeInc#9678)

Add supportsNativeTools: true to all Gemini-based models in the Vertex
provider. The VertexHandler extends GeminiHandler which already has full
native tool handling logic implemented.

Models updated:
- gemini-3-pro-preview
- gemini-2.5-flash-preview-05-20:thinking
- gemini-2.5-flash-preview-05-20
- gemini-2.5-flash
- gemini-2.5-flash-preview-04-17:thinking
- gemini-2.5-flash-preview-04-17
- gemini-2.5-pro-preview-03-25
- gemini-2.5-pro-preview-05-06
- gemini-2.5-pro-preview-06-05
- gemini-2.5-pro
- gemini-2.5-pro-exp-03-25
- gemini-2.0-pro-exp-02-05
- gemini-2.0-flash-001
- gemini-2.0-flash-lite-001
- gemini-2.0-flash-thinking-exp-01-21
- gemini-1.5-flash-002
- gemini-1.5-pro-002
- gemini-2.5-flash-lite-preview-06-17

* fix: display install count in millions instead of thousands (RooCodeInc#9677)

Co-authored-by: Roo Code <[email protected]>

* feat: add apply_patch native tool (RooCodeInc#9663)

Co-authored-by: daniel-lxs <[email protected]>

* feat: add debug buttons to view API and UI history (RooCodeInc#9684)

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* test(workflow): update test expectations after removing run_test functionality

* Add web-evals updates and kill run functionality (RooCodeInc#9681)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>
Co-authored-by: Roo Code <[email protected]>

* Add Grok 4 Fast and Grok 4.1 Fast, plus xAI native tool calling (RooCodeInc#9690)

* Add Grok 4 Fast and Grok 4.1 Fast

* Add native tool calling support

* Add native tool calling for deepinfra (RooCodeInc#9691)

* fix(chat): correct message visibility condition filter

* fix(utils): wrap os-name call in safe fallback for zgsm OS detection

* refactor(core): clean up unused imports and improve file handling logic

* refactor: adjust file limits and multipliers

* ux: Improvements to the new, RCC Provider centric onboarding flow (RooCodeInc#9709)

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>

* ux: Toolbar cleanup and settings consolidation (RooCodeInc#9710)

Co-authored-by: Roo Code <[email protected]>

* Update a couple provider labels (RooCodeInc#9711)

Co-authored-by: Roo Code <[email protected]>

* Release: v1.88.0 (RooCodeInc#9713)

* Remove TabContent wrapper from Modes and MCP (RooCodeInc#9712)

* fix: preserve tool_use blocks in summary for parallel tool calls (RooCodeInc#9714)

Co-authored-by: huajiwuyan <[email protected]>

* feat(chutes): detect native tool support from API supported_features (RooCodeInc#9715)

Co-authored-by: Matt Rubens <[email protected]>

* Add NTC support for Cerebras (RooCodeInc#9692)

* Add native tools support to Unbound (RooCodeInc#9699)

Co-authored-by: Roo Code <[email protected]>

* Add native tool support for vercel ai gateway (RooCodeInc#9697)

Co-authored-by: Roo Code <[email protected]>

* Default grok code fast to native tools (RooCodeInc#9717)

* Bedrock native tool calling (RooCodeInc#9698)

* Support tool calling in native ollama provider (RooCodeInc#9696)

Co-authored-by: Roo Code <[email protected]>

* feat: add native tool support for LiteLLM provider (RooCodeInc#9719)

* fix: prevent navigation buttons from wrapping on smaller screens (RooCodeInc#9721)

Co-authored-by: Roo Code <[email protected]>

* chore: add changeset for v3.35.0 (RooCodeInc#9724)

* Changeset version bump (RooCodeInc#9725)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* chore: bump version to v1.89.0 (RooCodeInc#9718)

* fix: flush pending tool results before task delegation (RooCodeInc#9726)

When tools are called in parallel (e.g., update_todo_list + new_task),
the tool results accumulate in userMessageContent but aren't saved to
API history until all tools complete. When new_task triggers delegation,
the parent is disposed before these pending results are saved, causing
400 errors when the parent resumes (missing tool_result for tool_use).

This fix:
- Adds flushPendingToolResultsToHistory() method in Task.ts that saves
  pending userMessageContent to API history
- Calls this method in delegateParentAndOpenChild() before disposing the
  parent task
- Safe for both native/XML protocols and sequential/parallel execution
  (returns early if there's nothing to flush)

* Better IPC error logging (RooCodeInc#9727)

* chore: add changeset for v3.35.1 (RooCodeInc#9728)

* Changeset version bump (RooCodeInc#9729)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* Pass app version to provider (RooCodeInc#9730)

* Allow models to contain default temperature (RooCodeInc#9734)

* Look for a tag in the Roo provider to default the model to native tool calling (RooCodeInc#9735)

* Assume all LiteLLM models support native tools (RooCodeInc#9736)

* chore: add changeset for v3.35.2 (RooCodeInc#9737)

* Changeset version bump (RooCodeInc#9738)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* Merge remote-tracking branch 'upstream/main' into roo-to-main

* Switch to new welcome view (RooCodeInc#9741)

* web: Homepage changes (RooCodeInc#9675)

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Add vendor confidentiality section to the system prompt for stealth models (RooCodeInc#9742)

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>

* chore: add changeset for v3.35.3 (RooCodeInc#9743)

* Changeset version bump (RooCodeInc#9745)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* Refactor: Remove line_count parameter from write_to_file tool (RooCodeInc#9667)

* fix: remove reasoning toggles for GLM-4.5 and GLM-4.6 on z.ai provider (RooCodeInc#9752)

Co-authored-by: Roo Code <[email protected]>

* fix: handle malformed native tool calls to prevent hanging (RooCodeInc#9758)

Co-authored-by: Matt Rubens <[email protected]>

* chore: add changeset for v3.35.4 (RooCodeInc#9763)

* Changeset version bump (RooCodeInc#9764)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* Convert the Roo provider tools for OpenAI (RooCodeInc#9769)

* Update the evals keygen command (RooCodeInc#9754)

* feat: Add provider routing selection for OpenRouter embeddings (RooCodeInc#9144) (RooCodeInc#9693)

Co-authored-by: Sannidhya <[email protected]>

* ux: Updates to CloudView (RooCodeInc#9776)

* refactor: remove TabHeader and onDone callback from CloudView

- Removed TabHeader component from CloudView as it is no longer needed
- Removed onDone prop from CloudView component definition and usage
- Updated all test files to reflect the removal of onDone prop
- Kept Button import that was accidentally removed initially

* Updates upsell copy to reflect today's product

* Update webview-ui/src/components/cloud/CloudView.tsx

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Update webview-ui/src/i18n/locales/ko/cloud.json

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Update webview-ui/src/i18n/locales/zh-CN/cloud.json

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Test fixes

---------

Co-authored-by: Roo Code <[email protected]>
Co-authored-by: Bruno Bergher <[email protected]>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Update model key for minimax in MODEL_DEFAULTS (RooCodeInc#9778)

Co-authored-by: Roo Code <[email protected]>

* Release v3.35.5 (RooCodeInc#9781)

* Changeset version bump (RooCodeInc#9783)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* Use search_and_replace for minimax (RooCodeInc#9780)

* fix: restore context when rewinding after condense (RooCodeInc#8295) (RooCodeInc#9665)

* fix: remove omission detection logic to fix false positives (RooCodeInc#9787)

Co-authored-by: Roo Code <[email protected]>

* Fix Vercel AI Gateway model fetching (RooCodeInc#9791)

Co-authored-by: Roo Code <[email protected]>

* refactor: remove insert_content tool (RooCodeInc#9751)

Co-authored-by: Roo Code <[email protected]>

* feat: add reasoning_details support to Roo provider (RooCodeInc#9796)

- Add currentReasoningDetails accumulator to track reasoning details
- Add getReasoningDetails() method to expose accumulated details
- Handle reasoning_details array format in streaming responses
- Accumulate reasoning details by type-index key
- Support reasoning.text, reasoning.summary, and reasoning.encrypted types
- Maintain backward compatibility with legacy reasoning format
- Follows same pattern as OpenRouter provider

Co-authored-by: Roo Code <[email protected]>

* chore: hide parallel tool calls experiment and disable feature (RooCodeInc#9798)

* Update next.js (RooCodeInc#9799)

* Fix the download count on the homepage (RooCodeInc#9807)

* Default to native tools for all models in the Roo provider (RooCodeInc#9811)

Co-authored-by: Roo Code <[email protected]>

* Fix/cerebras conservative max tokens (RooCodeInc#9804)

Co-authored-by: Matt Rubens <[email protected]>

* Release v3.36.0 (RooCodeInc#9814)

* Changeset version bump (RooCodeInc#9828)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* Merge remote-tracking branch 'upstream/main' into roo-to-main

* ux: improved error messages and documentation links (RooCodeInc#9777)

* Minor ui tweaks

* Basic setup for richer API request errors

* Better errors messages and contact link

* i18n

* Update webview-ui/src/i18n/locales/en/chat.json

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>

* Update webview-ui/src/i18n/locales/en/chat.json

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>

* Empty better than null

* Update webview-ui/src/i18n/locales/nl/chat.json

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* i18n

* Start retryAttempt at 1

* Reverse retryAttempt number, just ommit it from the message

---------