#6994·spring-ai

ToolResponse does not contains status about whether occur exception during execution.

Author: adj5672Created Sep 15, 2026Updated Sep 15, 2026
Labelsstatus: waiting-for-triage

Expected Behavior

Currently, ToolResponse only has id, name and responseData. And so I hope that ToolResponse has exception or any other thing which can distinguish whether exception is occurred during tool execution.

Current Behavior

java
String toolResult;
try {
	toolResult = toolCallback.call(finalToolInputArguments, toolContext);
}  catch (ToolExecutionException ex) {
	toolResult = this.toolExecutionExceptionProcessor.process(ex);
}

In DefaultToolCallingManager, if exception occur during the toolCallback.call such as invalid input argument, ExceptionProcessor return error message as toolResult. model receive it and retry tool call with modified input argument.

Even if ToolExecutionException is occurred, user only can judge whether error is thrown using string toolResult.

Context

When using stream chat response, I want to contains tool execution result as response to client. So I tried to implement streamAdvisor like below.

kotlin
class ToolExecutionResultAdvisor: StreamAdvisor {
    override fun adviseStream(chatClientRequest: ChatClientRequest, streamAdvisorChain: StreamAdvisorChain): Flux<ChatClientResponse> {
        val chatHistory = chatClientRequest.prompt.instructions
        val generations = ToolExecutionResult.buildGenerations { chatHistory }
        val chatClientResponse = if (generations.isNotEmpty()) ChatClientResponse.builder()
            .chatResponse(ChatResponse.builder()
                .generations(generations)
                .build())
            .build() else null

        return Mono.justOrEmpty(chatClientResponse)
            .concatWith(streamAdvisorChain.nextStream(chatClientRequest))
    }

    override fun getOrder(): Int {
        return ToolCallingAdvisor.DEFAULT_ORDER + 50
    }

    override fun getName(): String {
        return this::class.java.simpleName
    }
}

But as I said, if exception is thrown during tool execution, error message send to client directly. Furthermore, I cannot filter that response since cannot distinguish it whether exception is occurred or not.

Source: spring-projects/spring-ai