spring-projects / spring-projects/spring-ai
org.springframework.ai.chat.model.ToolContext No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Hello team,
Thank you for this repo.
Just wanted to let you know it seems there is an issue with https://github.com/spring-projects/spring-ai/blob/53eaf9a78493b1d91655575f4f8dcccbaf17a3a3/spring-ai-model/src/main/java/org/springframework/ai/chat/model/ToolContext.java#L46
Please see screenshot attached.
Would it be possible to add a default constructor? Something like:
public final class ToolContext {
/**
* The key for the running, tool call history stored in the context map.
*/
public static final String TOOL_CALL_HISTORY = "TOOL_CALL_HISTORY";
private Map<String, Object> context;
public ToolContext() {
}
/**
* Constructs a new ToolContext with the given context map.
* @param context A map containing the tool context information. This map is wrapped
* in an unmodifiable view to prevent changes.
*/
public ToolContext(Map<String, Object> context) {
this.context = Collections.unmodifiableMap(context);
}
/**
* Returns the immutable context map.
* @return An unmodifiable view of the context map.
*/
public Map<String, Object> getContext() {
return this.context;
}
/**
* Returns the tool call history from the context map.
* @return The tool call history. TODO: review whether we still need this or
* ToolCallingManager solves the original issue
*/
@SuppressWarnings("unchecked")
public List<Message> getToolCallHistory() {
return (List<Message>) this.context.get(TOOL_CALL_HISTORY);
}
}
Thank you for your help
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 with spring-ai-model/src/main/java/org/springframework/ai/chat/model/ToolContext.java around line 46 and inspect how the class is deserialized from an object. Reproduce the reported Jackson error using the attached example, then verify that the agreed constructor change allows deserialization without breaking the existing map-based construction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100