spring-projects / spring-projects/spring-ai
Replace IllegalStateException with ToolExecutionException for processor compatibility?
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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