Class AgentInvocation

java.lang.Object
dev.langchain4j.agentic.observability.AgentInvocation

public class AgentInvocation extends Object
  • Method Details

    • done

      public boolean done()
    • skipped

      public boolean skipped()
      Returns true if the agent was skipped instead of being invoked, because its activation condition was false or because it is optional and one of its arguments was missing.
    • skipReason

      public String skipReason()
      Returns why the agent was skipped, or null if it was invoked.
    • startTime

      public LocalDateTime startTime()
    • finishTime

      public LocalDateTime finishTime()
    • duration

      public Duration duration()
    • agent

      public AgentInstance agent()
    • agenticScope

      public AgenticScope agenticScope()
    • inputs

      public Map<String,Object> inputs()
    • output

      public Object output()
    • totalTokenCount

      public int totalTokenCount()
    • tokenUsage

      public Optional<TokenUsage> tokenUsage()
      Returns the token usage of the last LLM call of an AI agent, or of the decision call of a decision agent. It is empty if the agent called no model, like a workflow or a non-AI agent, if it was skipped, or if the provider didn't report the token usage.
    • modelName

      public Optional<String> modelName()
      Returns the name of the model that answered the last LLM call of an AI agent, or the decision call of a decision agent, as reported by the provider in the response metadata. It is empty if the agent called no model, like a workflow or a non-AI agent, if it was skipped, or if the provider didn't report the model name.
    • decisionResponse

      public Optional<DecisionResponse> decisionResponse()
      Returns the response of the decision model of a decision agent, with its answers and their probabilities. It is empty for every other kind of agent, and if the agent was skipped.
    • iterationIndex

      public int iterationIndex()
      Returns the zero-based iteration index when this invocation is part of a loop, or -1 otherwise.
    • nestedInvocations

      public List<AgentInvocation> nestedInvocations()
    • toolExecutions

      public List<ToolExecution> toolExecutions()
    • toString

      public String toString()
      Overrides:
      toString in class Object