Repository navigation
Conversation
…Scope function calling
1 task done
This branch has not been deployed
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.
Closes alibaba/spring-ai-alibaba#4966
问题
quick-start 的「构建一个基础 Agent」与「构建一个真实的 Agent」示例中,
FunctionToolCallback使用了.inputType(String.class),生成的工具参数 schema 是:{ "type": "string", "additionalProperties": false }而 DashScope 要求 function 的
parameters必须是 JSON object。结果是模型产出合法的tool_call后,第二轮把该 tool_call 回传时被服务端拒绝,照抄文档即复现 400:原因:
FunctionToolCallback.Builder.build()只依据inputType推导 schema(
JsonSchemaGenerator.generateForType(this.inputType)),不会读取apply()的方法签名,因此
String.class直接翻译成"type": "string"。改动
WeatherRequestrecord,inputType改为WeatherRequest.classWeatherForLocationTool@ToolParam移到 record 组件上UserLocationToolToolCallbackinputType改为对应 recordSYSTEM_PROMPTgetWeatherForLocation/getUserLocation)1.1.2.0(与「添加依赖」小节一致)HumanInTheLoopHookapprovalOn("getWeatherTool", ...)改为文档中真实存在的工具名System Prom→System Prompt验证
inputType(String.class))→ 稳定复现上述 400;inputType(WeatherRequest.class))→ 正常返回,工具被真实调用:环境:JDK 21.0.10 / Spring Boot 3.5.5 / agent-framework 1.1.2.0 / starter-dashscope 1.1.2.0 / 默认模型。