Class LLMCall<T>

Type Parameters:
T - the answer type the last outgoing message's handler declares
All Implemented Interfaces:
GuardedExecution, Identifiable, Job<T>, ModelDependent, ModelDependentTool<Void,T>, Tool<Void,T>

public class LLMCall<T> extends AbstractModelDependentTool<Void,T>
The one exchange a thinker's turn is, dispatched as a job of its own over the thinker's ConversationContext: the last outgoing message's ResponseHandler defines the answer type. Thinkers stay resource-free and spawn one of these per round-trip, so the reservation, the output budget and the truncation ceiling are scoped to the call alone, and the reservation is the input plus ConversationContext.resolveOutputBudget(), the same number the client sends as max_tokens.

The call is a model-dependent tool like every other exchange with a model in the runtime, built on AbstractModelDependentTool: the conversation is wired at requirements time, the exchange runs through converse, and a malformed answer is corrected under the shared ResponseCorrection budget. What is the call's own is its seat: the conversation's grade, its depth, and a pin when the thinker that spawned it is pinned, so a benchmark that pins a thinker pins every call it makes.

On OutputTruncationRetryException (raised by a client when the response hits stop_reason=max_tokens) the client has already bumped the outgoing message's requestedOutputTokens to the model ceiling; because the thinker's conversation is kept across attempts, the dispatcher's one-time re-run reserves and sends the escalated budget.

Since:
0.1 (2025-09-22)
Author:
Andrey Santrosyan
  • Field Details

    • MAX_CORRECTIONS

      public static final int MAX_CORRECTIONS
      Correction budget per job: at most this many parse/validation feedback retries.
      See Also:
  • Constructor Details

    • LLMCall

      public LLMCall(Identifiable parent, ConversationContext conversation)
      The model is the RESOLUTION's own, never an argument: this job declares the conversation's grade and depth through its seat, wires the resolved binding to the conversation, and the harness resolves it before execution - so the rate-limiter reservation, the output budget, the wire ceiling and the truncation ceiling all read one resolved cell and cannot silently diverge.
  • Method Details

    • getJobType

      public JobType getJobType()
      Description copied from interface: Job
      Gets the job type classification for analytics and cost attribution. Override in subclasses that need a specific type (TOOL, THINKER, DOER, etc.).
      Specified by:
      getJobType in interface Job<T>
      Overrides:
      getJobType in class AbstractTool<Void,T>
      Returns:
      the job type (default is JOB)
    • getGrade

      public Grade getGrade()
      The seat's grade is the conversation's, read and written there, never held by the call.
      Specified by:
      getGrade in interface ModelDependent
      Overrides:
      getGrade in class AbstractModelDependentTool<Void,T>
    • setGrade

      public void setGrade(Grade grade)
      Description copied from interface: ModelDependent
      Raises or lowers the declared grade for a run; a thinker refuses null.
      Specified by:
      setGrade in interface ModelDependent
      Overrides:
      setGrade in class AbstractModelDependentTool<Void,T>
    • getRole

      public ModelRole getRole()
      The seat's role is the conversation's too, stamped there from the thinker's declaration.
    • getRequirements

      public JobRequirements getRequirements()
      Description copied from class: AbstractTool
      Default requirements for tools. Subclasses should override to add database, LLM, or other requirements. JobType is handled by AbstractTool.getJobType(), not here.
      Specified by:
      getRequirements in interface Job<T>
      Overrides:
      getRequirements in class AbstractTool<Void,T>
      Returns:
      resource requirements, or null if the job needs no resources
    • execute

      public T execute(JobResources resources, JobContext<T> context) throws LLMReadableCheckedException
      Description copied from interface: Job
      Executes the job with the provided resources and context. A job reports progress and checks for cancellation through the context, and completes all its work before returning. A tool narrows this contract to the LLM-readable exceptions of Tool.execute(JobResources, JobContext).
      Parameters:
      resources - the allocated resources
      context - the job execution context for monitoring
      Returns:
      the job result, which may be null
      Throws:
      LLMReadableCheckedException - if execution fails
    • postExecute

      public void postExecute(JobContext<T> context)
      The answer is already recorded on the job as the call's response by the client wrapper; a tool's output metadata would repeat the whole turn beside it.
      Specified by:
      postExecute in interface Job<T>
      Overrides:
      postExecute in class AbstractTool<Void,T>
      Parameters:
      context - the job context