Record Class ToolContext

java.lang.Object
java.lang.Record
com.axelor.ai.tool.system.ToolContext
Record Components:
agents - the codes of the agents the call runs through, from the root to the one calling: a sub-agent is held to the reach of every agent that consulted it
chatId - the chat the call runs in, or null for a programmatic call with no chat
toolCallId - the call's id in the chat, or null
answer - the user's answer when the call carries on after a confirmation it asked for: true to carry on, false to decline; null otherwise
question - the id of the question answer answers, as the tool gave it; null otherwise
activeView - the context of the view open beside the chat when the message was sent, as the client builds it for the view's own actions — a form's values, unsaved edits included — or null
access - what the call may do for its user; null to decide for the current user when asked

public record ToolContext(List<String> agents, Set<Long> allowedKnowledgeBaseIds, Set<String> availableSkillCodes, String chatId, String toolCallId, Boolean answer, String question, Map<String,Object> activeView, Access access) extends Record
Execution context passed to system tools. Carries agent-scoped configuration so tools can enforce authorization server-side, and the call's place in a chat for a tool that can pause.
  • Field Details

  • Constructor Details

    • ToolContext

      public ToolContext(List<String> agents, Set<Long> allowedKnowledgeBaseIds, Set<String> availableSkillCodes, String chatId, String toolCallId, Boolean answer, String question, Map<String,Object> activeView)
      A context whose access is decided for the current user when asked.
    • ToolContext

      public ToolContext(List<String> agents, Set<Long> allowedKnowledgeBaseIds, Set<String> availableSkillCodes)
      A context outside any chat.
    • ToolContext

      public ToolContext(List<String> agents, Set<Long> allowedKnowledgeBaseIds, Set<String> availableSkillCodes, String chatId, String toolCallId, Boolean answer, String question)
      A context in a chat, with no view open beside it.
    • ToolContext

      public ToolContext(List<String> agents, Set<Long> allowedKnowledgeBaseIds, Set<String> availableSkillCodes, String chatId, String toolCallId, Boolean answer, String question, Map<String,Object> activeView, Access access)
      Creates an instance of a ToolContext record class.
      Parameters:
      agents - the value for the agents record component
      allowedKnowledgeBaseIds - the value for the allowedKnowledgeBaseIds record component
      availableSkillCodes - the value for the availableSkillCodes record component
      chatId - the value for the chatId record component
      toolCallId - the value for the toolCallId record component
      answer - the value for the answer record component
      question - the value for the question record component
      activeView - the value for the activeView record component
      access - the value for the access record component
  • Method Details

    • access

      public Access access()
      What the call may do: the access it was given, else its agents' for the current user, decided now. A tool asks once per call, since a fresh one decides afresh.
    • inChat

      public boolean inChat()
      Whether the call has a chat, and so a user who can be asked.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • agents

      public List<String> agents()
      Returns the value of the agents record component.
      Returns:
      the value of the agents record component
    • allowedKnowledgeBaseIds

      public Set<Long> allowedKnowledgeBaseIds()
      Returns the value of the allowedKnowledgeBaseIds record component.
      Returns:
      the value of the allowedKnowledgeBaseIds record component
    • availableSkillCodes

      public Set<String> availableSkillCodes()
      Returns the value of the availableSkillCodes record component.
      Returns:
      the value of the availableSkillCodes record component
    • chatId

      public String chatId()
      Returns the value of the chatId record component.
      Returns:
      the value of the chatId record component
    • toolCallId

      public String toolCallId()
      Returns the value of the toolCallId record component.
      Returns:
      the value of the toolCallId record component
    • answer

      public Boolean answer()
      Returns the value of the answer record component.
      Returns:
      the value of the answer record component
    • question

      public String question()
      Returns the value of the question record component.
      Returns:
      the value of the question record component
    • activeView

      public Map<String,Object> activeView()
      Returns the value of the activeView record component.
      Returns:
      the value of the activeView record component