Record Class LlmCallContext

java.lang.Object
java.lang.Record
com.agentforge4j.runtime.interceptor.LlmCallContext
Record Components:
runId - owning run id; never blank
stepId - step the call belongs to; may be null/blank when not step-scoped
agentId - the agent making the call; never blank
provider - the resolved provider name (e.g. "claude"); never blank
resolvedModel - the model the runtime resolved and will send; may be null for a provider default
maxOutputTokens - the request's generated-token cap, or null when unset (the embedding application falls back to its governing default)
assembledPromptLength - character length of the assembled system prompt plus user input (>= 0); a length, not a token count
cachedInputUnknown - whether cached-input status is unknown at this point (always true pre-call — size against the non-cached ceiling)

public record LlmCallContext(String runId, String stepId, String agentId, String provider, String resolvedModel, Integer maxOutputTokens, int assembledPromptLength, boolean cachedInputUnknown) extends Record
Neutral context for RunExecutionInterceptor.beforeLlmCall(LlmCallContext), supplied immediately before each LLM provider call (after model resolution, before dispatch).

Deliberately carries no prompt text: an embedding application that needs to size a worst-case cost envelope gets the assembled prompt's character length (a plain String.length(), not a tokenizer) and applies its own heuristic. Keeping OSS tokenizer-free and not spraying prompt content across this control SPI is intentional. Input-token counts are not known before the call (cachedInputUnknown() is therefore always true here); the actual usage is reconciled after the call via the existing LlmCallObserver / LLM_CALL_COMPLETED event.

  • Constructor Details

    • LlmCallContext

      public LlmCallContext(String runId, String stepId, String agentId, String provider, String resolvedModel, Integer maxOutputTokens, int assembledPromptLength, boolean cachedInputUnknown)
      Creates an instance of a LlmCallContext record class.
      Parameters:
      runId - the value for the runId record component
      stepId - the value for the stepId record component
      agentId - the value for the agentId record component
      provider - the value for the provider record component
      resolvedModel - the value for the resolvedModel record component
      maxOutputTokens - the value for the maxOutputTokens record component
      assembledPromptLength - the value for the assembledPromptLength record component
      cachedInputUnknown - the value for the cachedInputUnknown record component
  • Method Details

    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • runId

      public String runId()
      Returns the value of the runId record component.
      Returns:
      the value of the runId record component
    • stepId

      public String stepId()
      Returns the value of the stepId record component.
      Returns:
      the value of the stepId record component
    • agentId

      public String agentId()
      Returns the value of the agentId record component.
      Returns:
      the value of the agentId record component
    • provider

      public String provider()
      Returns the value of the provider record component.
      Returns:
      the value of the provider record component
    • resolvedModel

      public String resolvedModel()
      Returns the value of the resolvedModel record component.
      Returns:
      the value of the resolvedModel record component
    • maxOutputTokens

      public Integer maxOutputTokens()
      Returns the value of the maxOutputTokens record component.
      Returns:
      the value of the maxOutputTokens record component
    • assembledPromptLength

      public int assembledPromptLength()
      Returns the value of the assembledPromptLength record component.
      Returns:
      the value of the assembledPromptLength record component
    • cachedInputUnknown

      public boolean cachedInputUnknown()
      Returns the value of the cachedInputUnknown record component.
      Returns:
      the value of the cachedInputUnknown record component