Repository navigation
Model config: add tools - #16371
Model config: add tools#16371
Conversation
Signed-off-by: Jin Hai <[email protected]>
📝 WalkthroughWalkthroughThe model entity, provider listings, and GLM registry files were updated to describe tool support for selected models. ChangesGLM capability metadata
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
conf/models/zhipu-ai.json (2)
85-96: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winKeep
structured_outputconsistent with the aggregate catalog.
glm-4.7-flashx,glm-4.5-flash, andglm-4-flashare called out in the stack context as gaining JSON structured-output support inconf/all_models.json, but this provider registry only addstools. That leaves the same model names advertising different capabilities depending on which catalog is read.Also applies to: 183-195, 261-269
🤖 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 `@conf/models/zhipu-ai.json` around lines 85 - 96, The Zhipu AI model entries are missing the structured-output capability that is already advertised in the aggregate catalog, causing inconsistent capabilities for the same model names. Update the relevant model records in the provider registry for glm-4.7-flashx, glm-4.5-flash, and glm-4-flash to include structured_output alongside tools, matching the corresponding entries in conf/all_models.json and keeping the capabilities aligned across catalogs.
198-209: 🗄️ Data Integrity & Integration | 🟠 MajorAdd
chatandimage2texttoglm-4.5v
conf/models/zhipu-ai.jsonmarks this model asvisiononly, but the aggregate catalog lists it aschat,image2text, andvision. Keeping it vision-only makes it route/filter as a pure vision model even though it supports chat/tool use.🤖 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 `@conf/models/zhipu-ai.json` around lines 198 - 209, The glm-4.5v model entry is missing its non-vision capabilities, causing it to be treated as vision-only. Update the model metadata in the zhipu-ai configuration so the glm-4.5v definition includes chat and image2text alongside vision, keeping the existing thinking and tools settings intact. Use the glm-4.5v entry in the model catalog to ensure the capability list matches the aggregate catalog.
🤖 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 `@internal/entity/models/model.go`:
- Around line 420-428: The list serialization in model.go is flattening
capability objects into the string "supported" instead of preserving the full
capability payload. Update the modelData population in the relevant list
methods, especially where model.Thinking, model.Tools, and
model.StructuredOutput are handled, so they emit the full nested objects
consistently with the schema contract. Make sure tools and structured_output
respect the Support flag rather than checking only for non-nil pointers, and
preserve structured_output.types instead of dropping it.
---
Outside diff comments:
In `@conf/models/zhipu-ai.json`:
- Around line 85-96: The Zhipu AI model entries are missing the
structured-output capability that is already advertised in the aggregate
catalog, causing inconsistent capabilities for the same model names. Update the
relevant model records in the provider registry for glm-4.7-flashx,
glm-4.5-flash, and glm-4-flash to include structured_output alongside tools,
matching the corresponding entries in conf/all_models.json and keeping the
capabilities aligned across catalogs.
- Around line 198-209: The glm-4.5v model entry is missing its non-vision
capabilities, causing it to be treated as vision-only. Update the model metadata
in the zhipu-ai configuration so the glm-4.5v definition includes chat and
image2text alongside vision, keeping the existing thinking and tools settings
intact. Use the glm-4.5v entry in the model catalog to ensure the capability
list matches the aggregate catalog.
🪄 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: 8cee2b2b-fdc3-4dce-be6f-6310499135f4
📒 Files selected for processing (3)
conf/all_models.jsonconf/models/zhipu-ai.jsoninternal/entity/models/model.go
| if model.Thinking != nil { | ||
| modelData["thinking"] = "supported" | ||
| } | ||
| if model.Tools != nil { | ||
| modelData["tools"] = "supported" | ||
| } | ||
| if model.StructuredOutput != nil { | ||
| modelData["structured_output"] = "supported" | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Preserve the capability object instead of flattening it to "supported".
Line 408-410 already exposes the full thinking payload, but Lines 420-422 overwrite it with a string. The same flattening in both list methods also drops structured_output.types, and tools / structured_output are treated as supported whenever the pointer is non-nil, even if Support is false. That breaks the new schema contract these fields were added for.
Suggested fix
- if model.Thinking != nil {
- modelData["thinking"] = "supported"
- }
- if model.Tools != nil {
- modelData["tools"] = "supported"
- }
- if model.StructuredOutput != nil {
- modelData["structured_output"] = "supported"
- }
+ if model.Thinking != nil {
+ modelData["thinking"] = model.Thinking
+ }
+ if model.Tools != nil && model.Tools.Support {
+ modelData["tools"] = model.Tools
+ }
+ if model.StructuredOutput != nil && model.StructuredOutput.Support {
+ modelData["structured_output"] = model.StructuredOutput
+ }- if model.Thinking != nil {
- modelData["thinking"] = "supported"
- }
- if model.Tools != nil {
- modelData["tools"] = "supported"
- }
- if model.StructuredOutput != nil {
- modelData["structured_output"] = "supported"
- }
+ if model.Thinking != nil {
+ modelData["thinking"] = model.Thinking
+ }
+ if model.Tools != nil && model.Tools.Support {
+ modelData["tools"] = model.Tools
+ }
+ if model.StructuredOutput != nil && model.StructuredOutput.Support {
+ modelData["structured_output"] = model.StructuredOutput
+ }Also applies to: 496-504
🤖 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 `@internal/entity/models/model.go` around lines 420 - 428, The list
serialization in model.go is flattening capability objects into the string
"supported" instead of preserving the full capability payload. Update the
modelData population in the relevant list methods, especially where
model.Thinking, model.Tools, and model.StructuredOutput are handled, so they
emit the full nested objects consistently with the schema contract. Make sure
tools and structured_output respect the Support flag rather than checking only
for non-nil pointers, and preserve structured_output.types instead of dropping
it.
Signed-off-by: Jin Hai <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@internal/entity/models/model.go`:
- Around line 161-170: The exported Model contract is missing the
structured_output metadata, so JSON catalog entries containing it are not
preserved during unmarshalling. Update the Model struct to include a field for
structured_output alongside tools, using the same naming/tagging pattern as the
existing metadata fields so it round-trips through the catalog and list APIs.
Make sure the change is applied in the Model type and any related model metadata
handling that relies on this struct.
🪄 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: 782809f2-07ac-4e3f-b042-27cf29dd1a78
📒 Files selected for processing (3)
conf/all_models.jsonconf/models/zhipu-ai.jsoninternal/entity/models/model.go
💤 Files with no reviewable changes (2)
- conf/all_models.json
- conf/models/zhipu-ai.json
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
🤖 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 `@internal/entity/models/model.go`:
- Around line 161-170: The exported Model contract is missing the
structured_output metadata, so JSON catalog entries containing it are not
preserved during unmarshalling. Update the Model struct to include a field for
structured_output alongside tools, using the same naming/tagging pattern as the
existing metadata fields so it round-trips through the catalog and list APIs.
Make sure the change is applied in the Model type and any related model metadata
handling that relies on this struct.
🪄 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: 782809f2-07ac-4e3f-b042-27cf29dd1a78
📒 Files selected for processing (3)
conf/all_models.jsonconf/models/zhipu-ai.jsoninternal/entity/models/model.go
💤 Files with no reviewable changes (2)
- conf/all_models.json
- conf/models/zhipu-ai.json
🛑 Comments failed to post (1)
internal/entity/models/model.go (1)
161-170: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Restore
structured_outputon the exported model contract.This struct now carries
tools, but it no longer has anystructured_outputfield even though the PR objective says provider/catalog metadata should support it. That means anystructured_outputpayload in the JSON catalogs gets dropped at unmarshal time, so the list APIs cannot surface it downstream.🤖 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 `@internal/entity/models/model.go` around lines 161 - 170, The exported Model contract is missing the structured_output metadata, so JSON catalog entries containing it are not preserved during unmarshalling. Update the Model struct to include a field for structured_output alongside tools, using the same naming/tagging pattern as the existing metadata fields so it round-trips through the catalog and list APIs. Make sure the change is applied in the Model type and any related model metadata handling that relies on this struct.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16371 +/- ##
=======================================
Coverage 93.16% 93.16%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 668 668
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Type of change