Class ToolOutputDeduplicator

java.lang.Object
com.axelor.ai.chat.stream.ToolOutputDeduplicator

public class ToolOutputDeduplicator extends Object
Deduplicates a repeated tool call within a single stream request.

Tool outputs are never truncated: a tool result is the data the model reasons over, and cutting it mid-value silently corrupts it (a partial JSON schema read back and re-saved wipes the unread sections). Overall context-window pressure is handled coherently one layer up by ContextWindowPlugin, which summarizes/trims whole messages rather than mutilating any single one. This class therefore only collapses an exact repeat of a prior call — same tool, same input, same output — into a short reference note; the original, identical content is still present in history. Two different calls that happen to answer the same (two queries that both find nothing) are kept apart: a note pointing at the other call would read as "you already ran this" and hide the answer to the one just made.

One instance per stream request — not thread-safe.

  • Constructor Details

    • ToolOutputDeduplicator

      public ToolOutputDeduplicator()
  • Method Details

    • process

      public Object process(String toolCallId, String toolName, Object input, ToolResult.Success result)
      Processes a tool output before it is added to message history and streamed. Returns the original output unchanged, or — when this request already saw the same call with the same output — a short reference note pointing at the earlier call.