{"record":{"id":"ce7707b458d3ba01","repo":"alibaba/spring-ai-alibaba","slug":"last-message-is-not-an-assistantmessage-cannot-pr","errorCode":null,"errorMessage":"Last message is not an AssistantMessage, cannot process human feedback.","messagePattern":"Last message is not an AssistantMessage, cannot process human feedback\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/hook/hip/HumanInTheLoopHook.java","lineNumber":141,"sourceCode":"\t\t\t\tnewMessages.add(AssistantMessage.builder()\n\t\t\t\t\t.content(assistantMessage.getText())\n\t\t\t\t\t.properties(assistantMessage.getMetadata())\n\t\t\t\t\t.toolCalls(newToolCalls)\n\t\t\t\t\t.media(assistantMessage.getMedia())\n\t\t\t\t\t.build());\n\t\t\t\tnewMessages.add(new RemoveByHash<>(assistantMessage));\n\t\t\t}\n\n\t\t\t// ToolResponseMessages must be added after AssistantMessage\n\t\t\tif (!rejectedMessage.getResponses().isEmpty()) {\n\t\t\t\tnewMessages.add(rejectedMessage);\n\t\t\t}\n\n\t\t\tupdates.put(\"messages\", newMessages);\n\t\t\treturn CompletableFuture.completedFuture(updates);\n\t\t}\n\t\telse {\n\t\t\tlog.warn(\"Last message is not an AssistantMessage, cannot process human feedback.\");\n\t\t}\n\n\t\treturn CompletableFuture.completedFuture(Map.of());\n\t}\n\n\t@Override\n\tpublic Optional<InterruptionMetadata> interrupt(String nodeId, OverAllState state, RunnableConfig config) {\n\t\tAssistantMessage lastMessage = getLastAssistantMessage(state);\n\n\t\tif (lastMessage == null || !lastMessage.hasToolCalls()) {\n\t\t\treturn Optional.empty();\n\t\t}\n\n\t\tOptional<Object> feedback = config.metadata(RunnableConfig.HUMAN_FEEDBACK_METADATA_KEY);\n\t\tif (feedback.isPresent()) {\n\t\t\tif (!(feedback.get() instanceof InterruptionMetadata)) {\n\t\t\t\tthrow new IllegalArgumentException(\"Human feedback metadata must be of type InterruptionMetadata.\");\n\t\t\t}","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/hook/hip/HumanInTheLoopHook.java#L123-L159","documentation":"HumanInTheLoopHook.afterModel logs a warning when feedback rejection is requested but the last message is not an AssistantMessage — tool-call rewriting/removal can only apply to assistant messages carrying tool calls, so the feedback cannot be processed.","triggerScenarios":"Thrown at spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/hook/hip/HumanInTheLoopHook.java:141 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the interrupt happened after a model response containing tool calls","Verify message ordering in state before resuming with feedback","Ignore for non-tool-call interruptions; proceed without message rewriting"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}