Interface Job<T>

Type Parameters:
T - the type of result this job produces
All Superinterfaces:
Identifiable
All Known Subinterfaces:
AdmissionGuardrail, AuthGuardrail<T>, ContentGuardrail<T>, Doer<I,O>, Guardrail<T>, ModelDependentTool<I,O>, Orchestrator<I,O>, Thinker<I,O>, Tool<I,O>, ValidationGuardrail<T>
All Known Implementing Classes:
AbstractAdmissionGuardrail, AbstractAuthGuardrail, AbstractContentGuardrail, AbstractDoer, AbstractEPOTool, AbstractGuardrail, AbstractJob, AbstractModelDependentTool, AbstractOrchestrator, AbstractThinker, AbstractTool, AbstractToollessThinker, AbstractValidationGuardrail, AgentClassAllowListAdmissionGuardrail, AnalyzeViolationTool, Benchmark, BioRxivFetchTool, BioRxivSearchTool, CanonicalizeProductsTool, CaseAgent, ChatThinker, ClassifyFileTool, CurrentTimeTool, CustomerOrdersTool, CustomerOrderTool, CustomerReportDoer, DateCalculatorTool, DecideProductGroupsTool, DecisionCall, DecisionThinker, DecisionTool, DemoAgent, DemoBenchmark, DeterministicExtractTool, DisputeDoer, DurationCalculatorTool, EmailShiftDoer, EmbedTextTool, EPOBiblioTool, EPOClaimsTool, EPODescriptionTool, EPOFamilyTool, EPOFullTextTool, EPOImagesTool, EPOLegalStatusTool, EPONumberConversionTool, EPOSearchTool, EPOThinker, ExfiltrationMarkerGuardrail, ExtractDirectoryDoer, ExtractPricesTool, ExtractPricingDoer, FileNoteTool, GenericMCPToolAdapter, GetArtifactFieldTool, JudgeTool, ListFolderTool, LiteratureAggregator, LLMCall, OrderAgent, OrderStatusTool, PayloadSizeCapGuardrail, PdfVisionExtractTool, PIIDetectionGuardrail, PMCFullTextTool, PoiDeterministicExtractTool, PriceChangeFinder, PrincipalAllowListGuardrail, PubMedFetchTool, PubMedSearchTool, QuickLLMQuestionTool, ReactiveThinker, ReadDocumentTool, RemoteOrderStatusTool, RequestSkillTool, RequestToolsTool, SchemaConformanceGuardrail, SearchArtifactContentTool, SelectingAgent, SingleObjectiveThinker, SizeCapGuardrail, SplitStatementsTool, SubThinker, SummarizationTool, UnitRateCalculatorTool, UrlGuardrail, UsptoOdpContinuityTool, UsptoOdpFetchTool, UsptoOdpForeignPriorityTool, UsptoOdpFullTextTool, UsptoOdpLegalEventsTool, UsptoOdpSearchTool, UsptoOdpThinker, VisionExtractTool, WebFetchTool

public interface Job<T> extends Identifiable
Interface for all jobs that can be submitted to the job processing system. Jobs are units of work that declare their resource requirements and execute with provided resources.
Since:
0.1 (2025-08-11)
Author:
Andrey Santrosyan
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The transparent re-runs a job gets by default when the upstream answers with a retry signal.
  • Method Summary

    Modifier and Type
    Method
    Description
    execute(JobResources resources, JobContext<T> context)
    Executes the job with the provided resources and context.
    default String
    Returns a runtime-computed display name for this job instance, or null to use the @DisplayName annotation (or class simple name as fallback).
    Gets the unique job ID.
    default String
    Gets the unique job ID (alias for getId()).
    default JobType
    Gets the job type classification for analytics and cost attribution.
    Gets the user-friendly name for this job.
    int
    Gets the job priority (higher values = higher priority).
    Declares resource requirements for this job.
    default Duration
    Maximum time before the dispatcher times out and kills this job.
    default int
    How many transparent re-runs the dispatcher may give this job when the upstream fails with a retry signal (a 429, a 529, a plain 5xx or a connection failure), on one shared counter per execution; past them the job fails with the last signal as cause.
    default void
    Hook called after execution completes (success or failure), after resources are released, but before the terminal event is published.
    default void
    Hook called once per execution attempt, after resources are allocated and before the started event and execute(JobResources, JobContext).
    workflow(String userId, String workflowPrefix)
    Creates a workflow identity for root jobs.

    Methods inherited from interface Identifiable

    getParentJobId, getUserId, getWorkflowId
  • Field Details

    • DEFAULT_UPSTREAM_RETRIES

      static final int DEFAULT_UPSTREAM_RETRIES
      The transparent re-runs a job gets by default when the upstream answers with a retry signal. Three: the pre-emptive limiters keep a 429 rare and one re-run usually clears it, and a fault still there on the third attempt is an outage or a request the endpoint cannot serve, which more waiting never fixes.
      See Also:
  • Method Details

    • workflow

      static Identifiable workflow(String userId, String workflowPrefix)
      Creates a workflow identity for root jobs.
      Parameters:
      userId - user who owns the workflow
      workflowPrefix - readable prefix (e.g., "doc-ingest", "query-analysis")
      Returns:
      workflow identity for job constructors
      Throws:
      IllegalArgumentException - if userId or workflowPrefix is null/empty
    • getId

      String getId()
      Gets the unique job ID. Implements Identifiable.getJobId().
      Returns:
      the job ID
    • getJobId

      default String getJobId()
      Gets the unique job ID (alias for getId()). From Identifiable interface.
      Specified by:
      getJobId in interface Identifiable
      Returns:
      the job ID
    • getPriority

      int getPriority()
      Gets the job priority (higher values = higher priority).
      Returns:
      the priority
    • getName

      String getName()
      Gets the user-friendly name for this job.
      Returns:
      the job name
    • getRequirements

      JobRequirements getRequirements()
      Declares resource requirements for this job. Returns null for jobs that need no resources (e.g., orchestrators).
      Returns:
      resource requirements, or null if the job needs no resources
    • getDisplayName

      default String getDisplayName()
      Returns a runtime-computed display name for this job instance, or null to use the @DisplayName annotation (or class simple name as fallback).

      Override when the display name depends on instance state. For example, a sub-agent can return "Sub-Agent of (parent name)" without hardcoding that logic in the framework.

      Returns:
      instance-specific display name, or null for annotation-based default
    • getJobType

      default JobType getJobType()
      Gets the job type classification for analytics and cost attribution. Override in subclasses that need a specific type (TOOL, THINKER, DOER, etc.).
      Returns:
      the job type (default is JOB)
    • getTimeout

      default Duration getTimeout()
      Maximum time before the dispatcher times out and kills this job. Null means no deadline - the dispatcher schedules no killer (used by orchestrators, which only wait on tools).
      Returns:
      the timeout duration, or null for no timeout (default 30 minutes)
    • getUpstreamRetries

      default int getUpstreamRetries()
      How many transparent re-runs the dispatcher may give this job when the upstream fails with a retry signal (a 429, a 529, a plain 5xx or a connection failure), on one shared counter per execution; past them the job fails with the last signal as cause. The budget is this job's alone: a job that awaits this one receives that failure and fails once, without running its own body again, so budgets do not multiply with the depth of the job tree. The pacing window scales by attempt, so every re-run is minutes a caller waits behind: a job whose caller waits interactively sets fewer, an unattended pipeline may set more.
      Returns:
      the budget (default DEFAULT_UPSTREAM_RETRIES)
    • execute

      T execute(JobResources resources, JobContext<T> context) throws Exception
      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:
      Exception - if the job fails
      JobContext.CancellationException - if the job is cancelled
    • preExecute

      default void preExecute(JobContext<T> context)
      Hook called once per execution attempt, after resources are allocated and before the started event and execute(JobResources, JobContext). Use for pre-execution setup that needs the job context (e.g., stashing input for observability). Do NOT use for work that requires resources - that belongs in execute().
      Parameters:
      context - the job context
    • postExecute

      default void postExecute(JobContext<T> context)
      Hook called after execution completes (success or failure), after resources are released, but before the terminal event is published. Use for post-execution bookkeeping that needs to land in the terminal event's metadata (e.g., stashing output for observability). On success, the result is available via context.getResult().
      Parameters:
      context - the job context