diff --git a/easy-agents-agent-runtime/src/main/java/com/easyagents/agent/runtime/AgentResumeRequest.java b/easy-agents-agent-runtime/src/main/java/com/easyagents/agent/runtime/AgentResumeRequest.java
index b0e7494..e042bfc 100644
--- a/easy-agents-agent-runtime/src/main/java/com/easyagents/agent/runtime/AgentResumeRequest.java
+++ b/easy-agents-agent-runtime/src/main/java/com/easyagents/agent/runtime/AgentResumeRequest.java
@@ -35,7 +35,9 @@ public class AgentResumeRequest {
*
*
该字段仅供服务端集成层使用。普通调用方不应设置该标记;设置后 runtime 会跳过
* 当前进程内 {@code AgentToolApprovalCoordinator} 的 token 存在性校验,用于服务重启或跨节点后
- * 从 AgentScope session 中继续 pending tool。
+ * 从 AgentScope session 中继续 pending tool。批准请求必须在 metadata 中提供
+ * {@code toolCallId/toolName/toolInput},多个调用使用 {@code approvedToolCalls} 列表,
+ * 以便 runtime 将持久化审批结果绑定到实际工具调用。
*/
private boolean trusted;
diff --git a/easy-agents-agent-runtime/src/main/java/com/easyagents/agent/runtime/agentscope/AgentScopeReActRuntime.java b/easy-agents-agent-runtime/src/main/java/com/easyagents/agent/runtime/agentscope/AgentScopeReActRuntime.java
index 7530e33..1dcbdef 100644
--- a/easy-agents-agent-runtime/src/main/java/com/easyagents/agent/runtime/agentscope/AgentScopeReActRuntime.java
+++ b/easy-agents-agent-runtime/src/main/java/com/easyagents/agent/runtime/agentscope/AgentScopeReActRuntime.java
@@ -9,7 +9,9 @@ import com.easyagents.agent.runtime.event.observer.AgentRuntimeErrorObserver;
import com.easyagents.agent.runtime.event.observer.ReasoningLifecycleObserver;
import com.easyagents.agent.runtime.event.observer.SkillExecutionObserver;
import com.easyagents.agent.runtime.event.observer.ToolExecutionObserver;
+import com.easyagents.agent.runtime.hitl.AgentPendingState;
import com.easyagents.agent.runtime.hitl.AgentToolApprovalCoordinator;
+import com.easyagents.agent.runtime.hitl.AgentToolApprovalResolution;
import com.easyagents.agent.runtime.hitl.AgentToolApprovalRejectedException;
import com.easyagents.agent.runtime.knowledge.AgentKnowledgeSpec;
import com.easyagents.agent.runtime.knowledge.citation.AgentKnowledgeCitationMatcher;
@@ -153,6 +155,9 @@ public class AgentScopeReActRuntime implements AgentRuntime {
*/
@Override
public void close() {
+ if (approvalCoordinator != null) {
+ approvalCoordinator.cancelAll("Agent runtime has been closed.");
+ }
closeMcpClients();
initialized.set(false);
}
@@ -188,17 +193,27 @@ public class AgentScopeReActRuntime implements AgentRuntime {
return Flux.error(new AgentRuntimeException("Agent runtime is already streaming."));
}
AgentRuntimeExecutionContext executionContext = createResumeExecutionContext(request);
+ AgentToolApprovalResolution resolution = null;
try {
- if (!request.isTrusted()) {
- approvalCoordinator.consume(request);
+ if (request.isTrusted()) {
+ approvalCoordinator.authorizeTrustedExecution(request);
+ } else {
+ resolution = approvalCoordinator.resolve(request);
}
} catch (RuntimeException error) {
running.set(false);
throw error;
}
- // 审批拒绝
- if (!request.isApproved()) {
- executionContext.setCancelReason(request.getRejectReason());
+ if (resolution != null
+ && resolution.getStatus() == AgentToolApprovalResolution.Status.WAITING) {
+ return waitingForRemainingApprovals(executionContext, resolution);
+ }
+ if (!request.isApproved()
+ || resolution != null
+ && (resolution.getStatus() == AgentToolApprovalResolution.Status.REJECTED
+ || resolution.getStatus() == AgentToolApprovalResolution.Status.EXPIRED)) {
+ String cancelReason = resolution == null ? request.getRejectReason() : resolution.getReason();
+ executionContext.setCancelReason(cancelReason);
return Flux.defer(() -> {
saveSession();
return Flux.just(started(executionContext), cancelled(executionContext));
@@ -240,8 +255,6 @@ public class AgentScopeReActRuntime implements AgentRuntime {
AtomicReference finalMessage = new AtomicReference<>();
// HITL 暂停事件。被设置后,本轮以 SUSPENDED 挂起而不是 COMPLETED 结束。
AtomicReference suspendedEvent = new AtomicReference<>();
- // 本轮 HITL 待审批项来自旁路交互事件,最终会合并进 SUSPENDED 挂起事件。
- List