fix(ragflow): type rerankId as String to match the RAGFlow API - #2776
Merged
Conversation
RAGFlowConfig declared rerankId as Integer, but RAGFlow's /api/v1/retrieval endpoint identifies rerank models by name — e.g. "BAAI/bge-reranker-v2-m3@BAAI" or a hex UUID such as "b2a62730759d11ef987d0242ac120004". No Integer maps to a real model, so the rerank feature was unreachable through the Java SDK even though RAGFlowClient forwards the value verbatim as rerank_id. - rerankId field, builder field and getRerankId() are now String. - New Builder.rerankId(String) is the supported entry point. - Builder.rerankId(Integer) is kept as @deprecated(forRemoval = true) so existing call sites still compile; it stringifies the value. - docs/v1/{en,zh}/docs/task/rag.md showed .rerankId(1) in the RAGFlow config example, teaching the unusable form; both are updated. The explicit null guard in the deprecated overload is required: Integer binds to String.valueOf(Object), which turns null into the literal string "null" rather than null, and that would be sent as {"rerank_id": "null"}. Note this is not a fully source-compatible change: getRerankId() now returns String, so callers assigning it to an Integer must adapt. Keeping an Integer getter was rejected because it could never return a usable value for a name-based id. Only RAGFlowClient reads the getter inside this repository. Closes agentscope-ai#2740
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
jujn
approved these changes
Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AgentScope-Java Version
2.0.3-SNAPSHOT (
mainat bf7b7da)Description
Background
RAGFlowConfigdeclaresrerankIdasInteger, but RAGFlow's/api/v1/retrievalendpoint identifies rerank models by name, e.g."BAAI/bge-reranker-v2-m3@BAAI"or a hex UUID such as"b2a62730759d11ef987d0242ac120004".RAGFlowClientforwards the value verbatim:Since no
Integercorresponds to a real rerank model, there is no way to enable reranking through the Java SDK — the feature is unreachable, as reported in #2740. The existing Javadoc already described the field as the "rerank model ID", so the declared type contradicted its own documented meaning.Changes
rerankIdfield, builder field andgetRerankId()are nowString.Builder.rerankId(String)is the supported entry point, documented with both accepted ID forms.Builder.rerankId(Integer)is retained as@Deprecated(forRemoval = true)so existing builder call sites keep compiling; it stringifies the value.docs/v1/{en,zh}/docs/task/rag.mdupdated: the RAGFlow config example showed.rerankId(1), i.e. it was actively teaching the unusable form.On the null guard in the deprecated overload
The guard is not redundant. An
Integerargument binds toString.valueOf(Object)(reference widening resolves in overload phase 1, before unboxing is considered), and that overload mapsnullto the literal string"null"rather than tonull. Without the guard,.rerankId((Integer) null)would put{"rerank_id": "null"}on the wire — worse than omitting the field. Verified:nullRerankIdStaysNullForBothOverloadslocks this behaviour down for both overloads.Source compatibility — please read
This change is not fully source-compatible, and I want to be explicit rather than claim otherwise:
.rerankId(42)(builder)Integer id = config.getRerankId()StringKeeping an
Integer-returning getter alongside aStringfield was considered and rejected: it would need duplicated state and could never return a usable value for a name-based ID, so it would preserve compilation while guaranteeing incorrect behaviour.Practical exposure looks minimal:
RAGFlowClientis the only reader of the getter in this repository, and because no validIntegerever existed, callers are unlikely to be reading a meaningful value today. Still, this is the maintainers' call — happy to switch to a fully additive shape (leaveIntegerin place, add a separately namedStringaccessor) if you prefer to avoid the break entirely.How to test
New tests in
RAGFlowConfigTest.AdvancedFeaturesTest:shouldAcceptRerankIdAsModelName— both thevendor/model@providerand hex-UUID forms round-tripdeprecatedIntegerRerankIdIsStringified— the deprecated overload yields"42"nullRerankIdStaysNullForBothOverloads— neither overload produces the string"null"The tests were verified to actually exercise the fix: stubbing out
rerankId(String)turns 6 tests red, includingshouldAcceptRerankIdAsModelName.Relationship to open PRs
#2633 also touches this extension but only modifies
RAGFlowClient,RAGFlowKnowledgeandRAGFlowKnowledgeTest— it does not touchRAGFlowConfigorrerankId(diff checked), so there is no overlap.Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:apply(spotless:checkpasses)mvn test)docs/v1/en/docs/task/rag.mdand its Chinese counterpart both showed.rerankId(1)and are updated to a real model nameCloses #2740