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

Image

Comment From: jim-olsen

I will add that this also rears its head if using elicitations. Once you start an elicitation and use an exchange to exchange the information, the request can no longer be deserialized by the client as it now contains one of these objects. Until this is resolved elicitations are now unfortunately broken.

EDIT: Adding the fact that I am using 1.1.0 - M2