-
Notifications
You must be signed in to change notification settings - Fork 268
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.
Describe the bug
使用 OllamaChatModel 通过本地模型进行一个无入参工具的调用失败,仅把模型改为OpenAIChatModel 则能成功。
To Reproduce
Steps to reproduce the behavior:
package io.agentscope.examples.quickstart;
import io.agentscope.core.ReActAgent;
import io.agentscope.core.formatter.ollama.OllamaChatFormatter;
import io.agentscope.core.memory.InMemoryMemory;
import io.agentscope.core.model.OllamaChatModel;
import io.agentscope.core.tool.Tool;
import io.agentscope.core.tool.Toolkit;
import java.io.IOException;
import java.time.LocalDateTime;
public class LocalToolCallingExample {
public static void main(String[] args) throws IOException {
// 注册工具
Toolkit toolkit = new Toolkit();
toolkit.registerTool(new ExampleTool());
// 定义模型
// OpenAIChatModel model = OpenAIChatModel.builder()
// .modelName("qwen3:0.6b")
// .stream(false)
// .baseUrl("http://127.0.0.1:11434")
// .formatter(new OpenAIChatFormatter())
// .build();
OllamaChatModel model =
OllamaChatModel.builder()
.modelName("qwen3:0.6b")
.baseUrl("http://127.0.0.1:11434")
.formatter(new OllamaChatFormatter())
.build();
// 定义智能体
ReActAgent agent =
ReActAgent.builder()
.name("David")
.sysPrompt("你是一个名为逗你玩的智能体,请不要从上下文中找答案。")
.memory(new InMemoryMemory())
.model(model)
.toolkit(toolkit)
.build();
// Msg msg = Msg.builder()
// .name("张三")
// .textContent("现在是几点了?")
// .role(MsgRole.USER)
// .build();
//
// Msg response = agent.call(msg).block();
// System.out.println(response);
ExampleUtils.startChat(agent);
}
public static class ExampleTool {
@Tool(description = "获取当前时间")
public String getTime() {
System.out.println("=========》 getTime ");
return LocalDateTime.now().toString();
}
}
}Error messages
io.agentscope.core.tool.ToolExecutor Line:157 - Parameter validation failed for tool 'getTime': Schema validation error: argument "content" is null
实际输出
{
"model": "qwen3:0.6b",
"messages": [{
"role": "system",
"content": "你是一个名为逗你玩的智能体,请不要从上下文中找答案。"
}, {
"role": "user",
"content": "你通过工具调用的结果告诉我现在几点了。"
}, {
"role": "assistant",
"tool_calls": [{
"function": {
"name": "getTime",
"arguments": {}
}
}]
}, {
"role": "tool",
"content": "Error: Parameter validation failed for tool 'getTime': Schema validation error: argument \"content\" is null\nPlease correct the parameters and try again.",
"tool_call_id": "666bb26d-6bdf-4bd4-9a6c-5ad6346ccbe9",
"name": "getTime"
}],
"stream": true,
"tools": [{
"type": "function",
"function": {
"name": "getTime",
"description": "获取当前时间",
"parameters": {
"type": "object",
"properties": {}
}
}
}],
"options": {}
}Environment (please complete the following information):
- AgentScope-Java Version: [e.g. 1.0.7, check your pom.xml dependency version or run
mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)] - Java Version:17
- OS:windows
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done