spring-projects / spring-projects/spring-ai

Replace IllegalStateException with ToolExecutionException for processor compatibility?

Open
#6,816 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

Replace IllegalStateException with ToolExecutionException for processor compatibility?

Expected Behavior

In order for this exception to be properly caught and handled by the ToolExecutionExceptionProcessor, I would like to know if it is feasible to change the thrown exception type to ToolExecutionException.

If changing it to ToolExecutionException is not the intended design, is there any alternative way to handle this specific IllegalStateException (e.g., via a custom handler, wrapping it, or configuring the existing processor to intercept it)?

Looking forward to your suggestions. Thanks!

Current Behavior

Currently, an IllegalStateException is thrown at this location instead of a ToolExecutionException.

spring-ai-model/src/main/java/org/springframework/ai/model/tool/DefaultToolCallingManager.java

if (toolCallback == null) {
	if (logger.isWarnEnabled()) {
		logger.warn(POSSIBLE_LLM_TOOL_NAME_CHANGE_WARNING_START + toolName
				+ POSSIBLE_LLM_TOOL_NAME_CHANGE_WARNING_END);
	}
	throw new IllegalStateException("No ToolCallback found for tool name: " + toolName);   // <--- Not ToolExecutionException 
}

Context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in spring-ai-model/src/main/java/org/springframework/ai/model/tool/DefaultToolCallingManager.java and trace the null-toolCallback path. Read ToolExecutionException and ToolExecutionExceptionProcessor to determine how this exception is expected to be handled. Done means the compatibility decision is implemented or the supported handling alternative is clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.