agentscope-ai / agentscope-ai/agentscope-java

[Bug]:Please:When using PermissionContextState in conjunction with mcp, the ask rule invocation tool did not respond.

Aberta
#2,454 1 comentário 0 reações 0 responsáveis Ver no GitHub
area/build area/core/model area/core/tool area/ext/integration bug
Linguagem predominante
Java
Estrelas
5.6k
Forks
1.3k
Merge médio
4d 12h
PRs com merge (30d)
77

Descrição

**AgentScope-Java is an open-source project. To involve a broader community, we recommend asking your questions in English.**

**Describe the bug**
The structure of the Java project is agentscope 2.0.0 + mcp + agui. Among them, mcp and agui are both at version 1.0. Now, there is a problem. When I use PermissionContextState to control the tools in mcp, the addAllowRule can be executed successfully, but the addAskRule has no response and no error message is shown. It seems to be stuck without any inquiry.

**To Reproduce**
Steps to reproduce the behavior:

1.Here is the code for creating permissions that I have developed:
OpenAIChatModel model = buildLlm();
Toolkit useTk = mcpToolkit == null ? new Toolkit() : mcpToolkit;
PermissionContextState permCtx =
PermissionContextState.builder()
.mode(PermissionMode.DEFAULT)
.addAllowRule(
"list",
new PermissionRule(
"list",
null,
PermissionBehavior.ALLOW,
"userSettings"))
.addAskRule(
"delete",
new PermissionRule(
"delete", null, PermissionBehavior.ASK, "userSettings"))
.addAllowRule(
"update",
new PermissionRule(
"update", null, PermissionBehavior.ALLOW, "userSettings"))
.build();
return ReActAgent.builder()
.name("McpAgent")
.sysPrompt(mcpPrompt)
.permissionContext(permCtx)
.model(model)
.toolkit(useTk)
.stateStore(new InMemoryAgentStateStore())
//.hook(createTableFormatHook())
.enableMetaTool(true)
.build();

2.In the example index.html file of version 1.0 of agui, when calling the list and update tools, everything worked fine. However, when calling the delete function, there was no secondary confirmation prompt; instead, the program got stuck. Below is the response flow information:

data: {"type":"RUN_STARTED","threadId":"thread-1785221149212","runId":"run-1785221277873","input":{"threadId":"thread-1785221149212","runId":"run-1785221277873","messages":[{"id":"msg-1785221252611","role":"user","content":"列表","toolCalls":[],"toolCallId":null,"toolMessage":false,"systemMessage":false,"assistantMessage":false,"userMessage":true},{"id":"chatcmpl-9af0d248ca0dbc6d","role":"assistant","content":"\n\n","toolCalls":[],"toolCallId":null,"toolMessage":false,"systemMessage":false,"assistantMessage":true,"userMessage":false},{"id":"chatcmpl-895ce1a8089e2a4f","role":"assistant","content":"\n\n","toolCalls":[],"toolCallId":null,"toolMessage":false,"systemMessage":false,"assistantMessage":true,"userMessage":false},{"id":"chatcmpl-91ed2305abb8a659","role":"assistant","content":"\n\n以下是列表:xxxx列表","toolCalls":[],"toolCallId":null,"toolMessage":false,"systemMessage":false,"assistantMessage":true,"userMessage":false},{"id":"msg-1785221259808","role":"user","content":"修改xxxx数字为9666","toolCalls":[],"toolCallId":null,"toolMessage":false,"systemMessage":false,"assistantMessage":false,"userMessage":true},{"id":"chatcmpl-82254c6611b72f54","role":"assistant","content":"\n\n","toolCalls":[],"toolCallId":null,"toolMessage":false,"systemMessage":false,"assistantMessage":true,"userMessage":false},{"id":"chatcmpl-a652367d0c441c72","role":"assistant","content":"\n\n","toolCalls":[],"toolCallId":null,"toolMessage":false,"systemMessage":false,"assistantMessage":true,"userMessage":false},{"id":"chatcmpl-a524dd69f3305719","role":"assistant","content":"\n\n已成功将xxxx的数字修改为 9666。\n\n如果您需要查看修改后的数据或进行其他操作,请随时告诉我。","toolCalls":[],"toolCallId":null,"toolMessage":false,"systemMessage":false,"assistantMessage":true,"userMessage":false},{"id":"msg-1785221277872","role":"user","content":"删除xxxx数字","toolCalls":[],"toolCallId":null,"toolMessage":false,"systemMessage":false,"assistantMessage":false,"userMessage":true}],"tools":[],"context":[],"state":{},"forwardedProps":{}}}

data: {"type":"TEXT_MESSAGE_START","threadId":"thread-1785221149212","runId":"run-1785221277873","messageId":"chatcmpl-97110175e8f398ef","role":"assistant"}

data: {"type":"TEXT_MESSAGE_CONTENT","threadId":"thread-1785221149212","runId":"run-1785221277873","messageId":"chatcmpl-97110175e8f398ef","delta":"\n\n"}

data: {"type":"TEXT_MESSAGE_END","threadId":"thread-1785221149212","runId":"run-1785221277873","messageId":"chatcmpl-97110175e8f398ef"}

data: {"type":"TOOL_CALL_START","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a2c6582bdcb8cc56","toolCallName":"reset_equipped_tools"}

data: {"type":"TOOL_CALL_ARGS","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a2c6582bdcb8cc56","delta":"{\"to_activate\": "}

data: {"type":"TOOL_CALL_ARGS","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a2c6582bdcb8cc56","delta":"[\"delete\"]"}

data: {"type":"TOOL_CALL_ARGS","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a2c6582bdcb8cc56","delta":"}"}

data: {"type":"TOOL_CALL_END","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a2c6582bdcb8cc56"}

data: {"type":"TOOL_CALL_RESULT","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a2c6582bdcb8cc56","content":"The currently activated tool group(s): delete.\n\n删除指定模块中的某个配置项或资源\n","role":"tool","messageId":"e4b0eec5-ff8f-4c7b-84f4-099f47046811"}

data: {"type":"TEXT_MESSAGE_START","threadId":"thread-1785221149212","runId":"run-1785221277873","messageId":"chatcmpl-8d5f9e68c6fbf81d","role":"assistant"}

data: {"type":"TEXT_MESSAGE_CONTENT","threadId":"thread-1785221149212","runId":"run-1785221277873","messageId":"chatcmpl-8d5f9e68c6fbf81d","delta":"\n\n"}

data: {"type":"TEXT_MESSAGE_END","threadId":"thread-1785221149212","runId":"run-1785221277873","messageId":"chatcmpl-8d5f9e68c6fbf81d"}

data: {"type":"TOOL_CALL_START","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a5b553087fd0e033","toolCallName":"delete"}

data: {"type":"TOOL_CALL_ARGS","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a5b553087fd0e033","delta":"{\"modelName\": "}

data: {"type":"TOOL_CALL_ARGS","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a5b553087fd0e033","delta":"\""}

data: {"type":"TOOL_CALL_ARGS","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a5b553087fd0e033","delta":"mem"}

data: {"type":"TOOL_CALL_ARGS","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a5b553087fd0e033","delta":"\""}

data: {"type":"TOOL_CALL_ARGS","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a5b553087fd0e033","delta":", \"name\": "}

data: {"type":"TOOL_CALL_ARGS","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a5b553087fd0e033","delta":"\""}

data: {"type":"TOOL_CALL_ARGS","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a5b553087fd0e033","delta":"xxx"}

data: {"type":"TOOL_CALL_ARGS","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a5b553087fd0e033","delta":"\""}

data: {"type":"TOOL_CALL_ARGS","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a5b553087fd0e033","delta":"}"}

data: {"type":"TOOL_CALL_END","threadId":"thread-1785221149212","runId":"run-1785221277873","toolCallId":"chatcmpl-tool-a5b553087fd0e033"}

data: {"type":"RUN_FINISHED","threadId":"thread-1785221149212","runId":"run-1785221277873"}

**Expected behavior**
A clear and concise description of what you expected to happen.

**Error messages**
The normal procedure should be to ask for a second confirmation, and then decide whether to delete or not based on the result. However, there is no response at all now. Is it my usage that is the problem?

**Environment (please complete the following information):**

- AgentScope-Java Version: 2.0.0
- Java Version: [jdk17]
- OS: [ windows]

**Additional context**
The changes in version 2.0.0 are quite significant. Could you please enhance the related sample applications, especially those involving interactivity, such as the agui + mcp format that I use? The process of simply obtaining the message in the demo is a bit too straightforward.... thank you

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.