Skip to content

Model config: add tools - #16371

Merged
JinHai-CN merged 2 commits into
infiniflow:mainfrom
JinHai-CN:fix500
Jun 26, 2026
Merged

JinHai-CN merged 2 commits into
infiniflow:mainfrom
JinHai-CN:fix500

Conversation

@JinHai-CN

@JinHai-CN JinHai-CN commented Jun 26, 2026 •

Copy link
Copy Markdown
Member

What problem does this PR solve?

{
      "name": "glm-4-flash",
      "max_tokens": 128000,
      "model_types": [
        "chat"
      ],
      "tools": {
        "support": true
      }
}
RAGFlow(admin)> list provider 'zhipu-ai' models;
+------------+---------------+------------+---------------+----------------+-----------+-----------+
| dimensions | max_dimension | max_tokens | model_type    | name           | thinking  | tools     |
+------------+---------------+------------+---------------+----------------+-----------+-----------+
|            |               | 204800     | [chat]        | glm-5          | supported | supported |
|            |               | 204800     | [chat]        | glm-5-turbo    | supported | supported |

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

@JinHai-CN
JinHai-CN marked this pull request as ready for review June 26, 2026 02:50
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 26, 2026
@JinHai-CN JinHai-CN added ci Continue Integration and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 26, 2026
@dosubot dosubot Bot added the 🐞 bug Something isn't working, pull request that fix bug. label Jun 26, 2026
@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The model entity, provider listings, and GLM registry files were updated to describe tool support for selected models.

Changes

GLM capability metadata

Layer / File(s) Summary
Capability fields and types
internal/entity/models/model.go
The model entity adds an optional tools field backed by a new exported capability type.
Model listings expose support
internal/entity/models/model.go
ListAllModels and ListModels now emit "supported" for non-nil thinking and tools fields.
Zhipu registry metadata
conf/models/zhipu-ai.json
The zhipu-ai catalog adds tool support across multiple GLM model entries.
Aggregate catalog metadata
conf/all_models.json
The all_models catalog adds tool support to selected GLM entries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hop through JSON rows all day,
With tool flags added on display.
GLM models twitch their little ears,
“supported” now appears!
Crunch, crunch, hooray!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main change: adding tools support to model config.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR includes the required problem statement and type-of-change section, and the examples provide sufficient context for reviewers.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JinHai-CN
JinHai-CN marked this pull request as draft June 26, 2026 02:59
@JinHai-CN
JinHai-CN marked this pull request as ready for review June 26, 2026 02:59
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 win

Keep structured_output consistent with the aggregate catalog.

glm-4.7-flashx, glm-4.5-flash, and glm-4-flash are called out in the stack context as gaining JSON structured-output support in conf/all_models.json, but this provider registry only adds tools. 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 | 🟠 Major

Add chat and image2text to glm-4.5v
conf/models/zhipu-ai.json marks this model as vision only, but the aggregate catalog lists it as chat, image2text, and vision. 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

📥 Commits

Reviewing files that changed from the base of the PR and between dd2c88b and a8eff19.

📒 Files selected for processing (3)
  • conf/all_models.json
  • conf/models/zhipu-ai.json
  • internal/entity/models/model.go

Comment thread internal/entity/models/model.go Outdated
Comment on lines +420 to +428
if model.Thinking != nil {
modelData["thinking"] = "supported"
}
if model.Tools != nil {
modelData["tools"] = "supported"
}
if model.StructuredOutput != nil {
modelData["structured_output"] = "supported"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ 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.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 26, 2026
@JinHai-CN JinHai-CN changed the title Model config: add tool and structure output supported Model config: add tools Jun 26, 2026
@JinHai-CN
JinHai-CN marked this pull request as draft June 26, 2026 03:07
@JinHai-CN
JinHai-CN marked this pull request as ready for review June 26, 2026 03:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between a8eff19 and 9bd103d.

📒 Files selected for processing (3)
  • conf/all_models.json
  • conf/models/zhipu-ai.json
  • internal/entity/models/model.go
💤 Files with no reviewable changes (2)
  • conf/all_models.json
  • conf/models/zhipu-ai.json

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between a8eff19 and 9bd103d.

📒 Files selected for processing (3)
  • conf/all_models.json
  • conf/models/zhipu-ai.json
  • internal/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_output on the exported model contract.

This struct now carries tools, but it no longer has any structured_output field even though the PR objective says provider/catalog metadata should support it. That means any structured_output payload 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

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (dd2c88b) to head (9bd103d).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JinHai-CN
JinHai-CN merged commit 65afaa1 into infiniflow:main Jun 26, 2026
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant