feat(models): add GLM-4.7 model support via OpenRouter - #580
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughRenames an existing GLM-4.7 model ID, adds a new OpenRouter preset provider+model in Changes
Sequence Diagram(s)sequenceDiagram
participant User as User (shell)
participant Fish as Fish abbrev (pixe/pixeh)
participant Pi as pi-agent
participant Config as models.json (provider)
participant Provider as OpenRouter API
rect rgba(200,230,255,0.5)
User->>Fish: invoke `pixe [args]` or `pixeh`
Fish->>Fish: assemble prompt (args or read input)
Fish->>Pi: run pi-agent "<prompt>" -m 'openrouter-preset/@preset/glm-4-7'
end
rect rgba(220,255,200,0.5)
Pi->>Config: resolve model id `openrouter-preset/@preset/glm-4-7`
Pi->>Provider: send request to OpenRouter (apiKey/baseUrl)
Provider-->>Pi: model response
Pi-->>User: output result
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (6)**/*.nix📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/default.nix📄 CodeRabbit inference engine (CLAUDE.md)
Files:
home-manager/programs/*/default.nix📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
Files:
home-manager/programs/**/default.nix📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
Files:
home-manager/**/*.nix📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
Files:
home-manager/programs/**/*.nix📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
🔇 Additional comments (2)
✏️ Tip: You can disable this entire section by setting Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @shunkakinoki, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates the GLM-4.7 model into the system via an OpenRouter preset, significantly enhancing the range of available AI capabilities. It includes the necessary configuration for the new model, featuring a substantial context window, and provides convenient shell shortcuts for users to easily interact with it. The changes aim to broaden model options and improve user experience by simplifying access to advanced AI functionalities. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Mesa DescriptionTL;DRAdded GLM-4.7 model support via an OpenRouter preset, including an increased context window, and introduced What changed?
Description generated by Mesa. Update settings |
There was a problem hiding this comment.
Code Review
This pull request adds support for the GLM-4.7 model via OpenRouter by updating the model configuration and adding new fish shell functions for quick access. The changes are generally good, but I have a few suggestions to improve consistency, maintainability, and correctness. Specifically, I've pointed out an inconsistent model name, the inclusion of what appear to be extraneous function definitions in the Nix configuration, and opportunities to refactor hardcoded model IDs in the new fish functions.
| "_pilxe_function" | ||
| "_pilxeh_function" |
There was a problem hiding this comment.
| "id": "z-ai/glm-4.7", | ||
| "name": "GLM-4.7 (Z-AI)", | ||
| "id": "z-ai/glm-4-7", | ||
| "name": "glm-4-7 (Z-AI)", |
There was a problem hiding this comment.
For consistency with other model names in this file (e.g., GLM-4.6 (Z-AI) on line 162 and the new GLM-4.7 (Z-AI) on line 185), the model name should be capitalized. This improves readability and maintains a consistent naming convention across the configuration.
| "name": "glm-4-7 (Z-AI)", | |
| "name": "GLM-4.7 (Z-AI)", |
| if test (count $argv) -eq 0 | ||
| pi-agent -m 'openrouter-preset/@preset/glm-4-7' | ||
| else | ||
| set -l prompt (string join " " -- $argv) | ||
| pi-agent "$prompt" -m 'openrouter-preset/@preset/glm-4-7' | ||
| end |
There was a problem hiding this comment.
To improve maintainability and avoid duplicating the model identifier string, it's a good practice to define it as a local variable. This makes it easier to update in the future if needed.
set -l model 'openrouter-preset/@preset/glm-4-7'
if test (count $argv) -eq 0
pi-agent -m "$model"
else
set -l prompt (string join " " -- $argv)
pi-agent "$prompt" -m "$model"
end
|
|
||
| pi-agent "$prompt" -m 'openrouter-preset/@preset/glm-4-7' |
There was a problem hiding this comment.
Performed full review of 3657500...527e8b3
Analysis
-
Build Failure Risk: The fish configuration references
_pilxe_functionand_pilxh_functionthat don't exist in the PR, which will cause the Nix build to fail. -
Breaking Change: The model ID changed from
z-ai/glm-4.7toz-ai/glm-4-7, which may break existing configurations or scripts without proper migration guidance. -
Potential User Confusion: Having two ways to access GLM-4.7 (directly via
z-ai/glm-4-7and through@preset/glm-4-7) may confuse users about which approach to use when. -
Missing API Key Validation: The preset configuration uses
OPENROUTER_API_KEYbut the fish functions don't verify this environment variable is set before making API calls.
Tip
Help
Slash Commands:
/review- Request a full code review/review latest- Review only changes since the last review/describe- Generate PR description. This will update the PR body or issue comment depending on your configuration/help- Get help with Mesa commands and configuration options
0 files reviewed | 3 comments | Edit Agent Settings • Read Docs
| "_dev_function" | ||
| "_ocxe_function" | ||
| "_ocxeh_function" | ||
| "_pilxe_function" |
There was a problem hiding this comment.
These function references (_pilxe_function and _pilxeh_function) appear to be added but the corresponding function files are not present in this PR. This will cause the fish shell configuration to fail at build time when it tries to source non-existent files. Either these entries should be removed or the function files need to be added.
Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#580
File: home-manager/programs/fish/default.nix#L154
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.
Feedback:
These function references (`_pilxe_function` and `_pilxeh_function`) appear to be added but the corresponding function files are not present in this PR. This will cause the fish shell configuration to fail at build time when it tries to source non-existent files. Either these entries should be removed or the function files need to be added.
| { | ||
| "id": "z-ai/glm-4.7", | ||
| "name": "GLM-4.7 (Z-AI)", | ||
| "id": "z-ai/glm-4-7", |
There was a problem hiding this comment.
This model ID change from z-ai/glm-4.7 to z-ai/glm-4-7 (dot to hyphen) should be carefully verified. If this is correcting a typo to match OpenRouter's actual model identifier, that's fine. However, if existing configurations or scripts reference the old ID z-ai/glm-4.7, they will break. Consider checking for any hardcoded references to the old model ID.
Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#580
File: config/pi/models.json#L145
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.
Feedback:
This model ID change from `z-ai/glm-4.7` to `z-ai/glm-4-7` (dot to hyphen) should be carefully verified. If this is correcting a typo to match OpenRouter's actual model identifier, that's fine. However, if existing configurations or scripts reference the old ID `z-ai/glm-4.7`, they will break. Consider checking for any hardcoded references to the old model ID.
| "api": "openai-completions", | ||
| "models": [ | ||
| { | ||
| "id": "@preset/glm-4-7", |
There was a problem hiding this comment.
The model ID uses the @preset/ prefix which appears to be OpenRouter-specific syntax. Verify that the Pi agent correctly handles this prefix when constructing API requests. Also, there's a discrepancy: this entry uses @preset/glm-4-7 while the direct model on line 145 uses z-ai/glm-4-7. Consider documenting when to use each variant.
Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#580
File: config/pi/models.json#L184
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.
Feedback:
The model ID uses the `@preset/` prefix which appears to be OpenRouter-specific syntax. Verify that the Pi agent correctly handles this prefix when constructing API requests. Also, there's a discrepancy: this entry uses `@preset/glm-4-7` while the direct model on line 145 uses `z-ai/glm-4-7`. Consider documenting when to use each variant.
There was a problem hiding this comment.
Pull request overview
This PR adds support for the GLM-4.7 model via OpenRouter's preset system, providing a free alternative for running Pi agent. It updates the model ID format, adds a new OpenRouter provider configuration, and creates fish shell shortcuts for easy access.
Changes:
- Added
openrouter-presetprovider configuration with GLM-4.7 model - Updated existing GLM-4.7 model ID from
z-ai/glm-4.7toz-ai/glm-4-7in thecli-proxy-apiprovider - Created
pixeandpixehfish functions for running Pi agent with GLM-4.7
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| config/pi/models.json | Added openrouter-preset provider with GLM-4.7 model, corrected model ID format for existing entry |
| home-manager/programs/fish/functions/_pixe_function.fish | New fish function for running Pi agent with GLM-4.7 via OpenRouter |
| home-manager/programs/fish/functions/_pixeh_function.fish | New fish function for running Pi agent headlessly with GLM-4.7 |
| home-manager/programs/fish/default.nix | Added abbreviations for pixe/pixeh and registered function files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "_pilxe_function" | ||
| "_pilxeh_function" |
There was a problem hiding this comment.
The functions _pilxe_function and _pilxeh_function are referenced but don't exist in the functions directory. These should be removed from the list, or the corresponding function files need to be created.
| "_pilxe_function" | |
| "_pilxeh_function" |
| # Usage: pixe [<prompt words...>] | ||
|
|
||
| if test (count $argv) -eq 0 | ||
| pi-agent -m 'openrouter-preset/@preset/glm-4-7' |
There was a problem hiding this comment.
Inconsistent model ID format. The existing _ocxe_function.fish uses openrouter-preset/glm-4-7 while this uses openrouter-preset/@preset/glm-4-7. The JSON configuration defines the model ID as @preset/glm-4-7, so the format openrouter-preset/@preset/glm-4-7 appears correct, but _ocxe_function.fish should likely be updated for consistency.
| pi-agent -m 'openrouter-preset/@preset/glm-4-7' | ||
| else | ||
| set -l prompt (string join " " -- $argv) | ||
| pi-agent "$prompt" -m 'openrouter-preset/@preset/glm-4-7' |
There was a problem hiding this comment.
Inconsistent model ID format. The existing _ocxe_function.fish uses openrouter-preset/glm-4-7 while this uses openrouter-preset/@preset/glm-4-7. The JSON configuration defines the model ID as @preset/glm-4-7, so the format openrouter-preset/@preset/glm-4-7 appears correct, but _ocxe_function.fish should likely be updated for consistency.
| return 1 | ||
| end | ||
|
|
||
| pi-agent "$prompt" -m 'openrouter-preset/@preset/glm-4-7' |
There was a problem hiding this comment.
Inconsistent model ID format. The existing _ocxe_function.fish uses openrouter-preset/glm-4-7 while this uses openrouter-preset/@preset/glm-4-7. The JSON configuration defines the model ID as @preset/glm-4-7, so the format openrouter-preset/@preset/glm-4-7 appears correct, but _ocxe_function.fish should likely be updated for consistency.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@home-manager/programs/fish/default.nix`:
- Around line 154-157: The function list contains _pilxe_function and
_pilxeh_function but their files
(home-manager/programs/fish/functions/_pilxe_function.fish and
_pilxeh_function.fish) and shell abbreviations (pilxe, pilxeh in shellAbbrs) are
missing; either remove "_pilxe_function" and "_pilxeh_function" from the array
in default.nix or add the corresponding .fish files under
programs/fish/functions/ and define matching shellAbbrs entries ("pilxe" and
"pilxeh") so the functions can be sourced without error.
🧹 Nitpick comments (1)
config/pi/models.json (1)
145-146: Minor naming inconsistency between providers.The model name here is
"glm-4-7 (Z-AI)"(lowercase, no dot), while the newopenrouter-presetprovider at line 185 uses"GLM-4.7 (Z-AI)"(uppercase, with dot). Consider aligning the naming convention for consistency across providers.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
config/pi/models.jsonhome-manager/programs/fish/default.nixhome-manager/programs/fish/functions/_pixe_function.fishhome-manager/programs/fish/functions/_pixeh_function.fish
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{js,ts,jsx,tsx,json}
📄 CodeRabbit inference engine (CLAUDE.md)
Use Biome with 2-space indentation, 80-character line width, double quotes, and trailing commas (ES5) for JSON/JavaScript/TypeScript files
Files:
config/pi/models.json
**/*.{json,yaml,yml,toml}
📄 CodeRabbit inference engine (.cursor/rules/formatting.mdc)
**/*.{json,yaml,yml,toml}: Use consistent indentation (2 spaces) in configuration files
Sort keys alphabetically when possible in configuration files
Use clear, descriptive names in configuration files
Files:
config/pi/models.json
**/*.{js,jsx,ts,tsx,json}
📄 CodeRabbit inference engine (.cursor/rules/formatting.mdc)
**/*.{js,jsx,ts,tsx,json}: Format JavaScript/TypeScript/JSON files using Biome with 2-space indentation and 80 character line width
Enable Biome linter with recommended rules for JavaScript/TypeScript/JSON files
Files:
config/pi/models.json
**/*.{js,jsx,ts,tsx,json,jsonc,md}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Use Biome for code formatting as configured in biome.json
Files:
config/pi/models.json
**/*.nix
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.nix: Use nixfmt for formatting all Nix files
Document complex configurations with comments in Nix files
**/*.nix: Use 2 spaces for indentation in Nix files
Keep line length under 100 characters in Nix files
Sort attribute sets alphabetically in Nix files
Use consistent spacing around operators in Nix files
Format lists and sets consistently in Nix filesUse treefmt.toml for formatting Nix files
**/*.nix: UsemkOptionfor configurable options in Nix modules
Implement proper typing for all options in Nix modules
Follow the Nix expression language style guide
Files:
home-manager/programs/fish/default.nix
**/default.nix
📄 CodeRabbit inference engine (CLAUDE.md)
Use
default.nixfiles for module exports
Files:
home-manager/programs/fish/default.nix
home-manager/programs/*/default.nix
📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
Program configurations should be located in
home-manager/programs/<name>/and use home-manager's built-in modules when available
Files:
home-manager/programs/fish/default.nix
home-manager/programs/**/default.nix
📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
Program configurations must include all necessary dependencies in their configuration
Files:
home-manager/programs/fish/default.nix
home-manager/**/*.nix
📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
home-manager/**/*.nix: Use typed options whenever possible in Nix configurations
Document all configuration options in Nix modules and programs
Follow home-manager's module structure and keep configurations modular
Use proper indentation and formatting in Nix configuration files
Files:
home-manager/programs/fish/default.nix
home-manager/programs/**/*.nix
📄 CodeRabbit inference engine (.cursor/rules/home-manager.mdc)
Follow program-specific best practices in program configuration files
Program configurations in
home-manager/programs/should be organized by program name, include all necessary dependencies, usehome.packagesfor package installations, and useprograms.<name>when available in home-manager
Files:
home-manager/programs/fish/default.nix
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
- GitHub Check: Agent
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Mesa Review
- GitHub Check: e2e-run (Ubuntu, ubuntu-latest)
- GitHub Check: e2e-run (NixOS, ubuntu-latest)
- GitHub Check: e2e-run (MacOS, macos-latest)
- GitHub Check: shell-test
- GitHub Check: shell-lint
- GitHub Check: docker-build-push (linux/arm64, arm64, ubuntu-24.04-arm)
- GitHub Check: lua-hammerspoon
- GitHub Check: docker-build-push (linux/amd64, amd64, ubuntu-latest)
- GitHub Check: lua-neovim
- GitHub Check: lua-neovim-test
- GitHub Check: nix-linux
- GitHub Check: nix-nixos
- GitHub Check: nix-darwin
🔇 Additional comments (4)
home-manager/programs/fish/functions/_pixeh_function.fish (1)
1-12: LGTM!The function correctly validates user input, provides appropriate error handling with stderr output, and uses the correct model reference (
openrouter-preset/@preset/glm-4-7) that matches the new provider configuration inmodels.json.home-manager/programs/fish/functions/_pixe_function.fish (1)
1-11: LGTM!The function provides flexible usage with both interactive mode (no arguments) and direct prompt mode. The use of
string join " " -- $argvis idiomatic Fish and safely handles arguments that might start with dashes. The model reference is consistent with_pixeh_functionandmodels.json.home-manager/programs/fish/default.nix (1)
91-92: LGTM!The abbreviations correctly map
pixeandpixehto their corresponding functions, following the existing pattern in the configuration.config/pi/models.json (1)
178-199: New OpenRouter preset provider configuration is correct.The structure follows the existing provider pattern with appropriate fields.
API Key handling: The
apiKeyvalue"OPENROUTER_API_KEY"is a runtime reference that pi-agent resolves at startup via its AuthStorage mechanism, which reads from environment variables,~/.pi/agent/auth.json, or CLI flags. This format is correct for pi-agent. As a security best practice, ensure the actual key is supplied via theOPENROUTER_API_KEYenvironment variable or stored in auth.json, not embedded in this config file.API endpoint: The
"openai-completions"API type is compatible with OpenRouter, which provides OpenAI-compliant/v1/chat/completionsand/v1/completionsendpoints. Test provider-specific features (streaming, function calling, model-specific behaviors) during integration to confirm full compatibility.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="home-manager/programs/fish/default.nix">
<violation number="1" location="home-manager/programs/fish/default.nix:154">
P1: xdg.configFile installs Fish functions `_pilxe_function`/`_pilxeh_function` that don't exist, causing build/activation failure or unused config (likely typo vs `_pixe*`)</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| "_dev_function" | ||
| "_ocxe_function" | ||
| "_ocxeh_function" | ||
| "_pilxe_function" |
There was a problem hiding this comment.
P1: xdg.configFile installs Fish functions _pilxe_function/_pilxeh_function that don't exist, causing build/activation failure or unused config (likely typo vs _pixe*)
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/programs/fish/default.nix, line 154:
<comment>xdg.configFile installs Fish functions `_pilxe_function`/`_pilxeh_function` that don't exist, causing build/activation failure or unused config (likely typo vs `_pixe*`)</comment>
<file context>
@@ -149,6 +151,10 @@
"_dev_function"
"_ocxe_function"
"_ocxeh_function"
+ "_pilxe_function"
+ "_pilxeh_function"
+ "_pixe_function"
</file context>
Changes
z-ai/glm-4.7toz-ai/glm-4-7openai-completionspixeandpixehfish shortcuts for quick GLM-4.7 accessTechnical Details
Testing
Generated with Claude Code by Claude 3.5 Sonnet
Summary by cubic
Add GLM-4.7 support via an OpenRouter preset and new fish shortcuts to run Pi agent with this model. Uses the openai-completions endpoint and increases the context window for longer prompts.
New Features
Refactors
Written for commit be5391e. Summary will update on new commits.