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
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
FieldsModifier and TypeFieldDescriptionstatic final intThe transparent re-runs a job gets by default when the upstream answers with a retry signal. -
Method Summary
Modifier and TypeMethodDescriptionexecute(JobResources resources, JobContext<T> context) Executes the job with the provided resources and context.default StringReturns a runtime-computed display name for this job instance, or null to use the@DisplayNameannotation (or class simple name as fallback).getId()Gets the unique job ID.default StringgetJobId()Gets the unique job ID (alias for getId()).default JobTypeGets the job type classification for analytics and cost attribution.getName()Gets the user-friendly name for this job.intGets the job priority (higher values = higher priority).Declares resource requirements for this job.default DurationMaximum time before the dispatcher times out and kills this job.default intHow 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 voidpostExecute(JobContext<T> context) Hook called after execution completes (success or failure), after resources are released, but before the terminal event is published.default voidpreExecute(JobContext<T> context) Hook called once per execution attempt, after resources are allocated and before the started event andexecute(JobResources, JobContext).static IdentifiableCreates a workflow identity for root jobs.Methods inherited from interface Identifiable
getParentJobId, getUserId, getWorkflowId
-
Field Details
-
DEFAULT_UPSTREAM_RETRIES
static final int DEFAULT_UPSTREAM_RETRIESThe 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
Creates a workflow identity for root jobs.- Parameters:
userId- user who owns the workflowworkflowPrefix- readable prefix (e.g., "doc-ingest", "query-analysis")- Returns:
- workflow identity for job constructors
- Throws:
IllegalArgumentException- if userId or workflowPrefix is null/empty
-
getId
-
getJobId
Gets the unique job ID (alias for getId()). FromIdentifiableinterface.- Specified by:
getJobIdin interfaceIdentifiable- Returns:
- the job ID
-
getPriority
int getPriority()Gets the job priority (higher values = higher priority).- Returns:
- the priority
-
getName
-
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
Returns a runtime-computed display name for this job instance, or null to use the@DisplayNameannotation (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
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
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
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 ofTool.execute(JobResources, JobContext).- Parameters:
resources- the allocated resourcescontext- the job execution context for monitoring- Returns:
- the job result, which may be null
- Throws:
Exception- if the job failsJobContext.CancellationException- if the job is cancelled
-
preExecute
Hook called once per execution attempt, after resources are allocated and before the started event andexecute(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
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
-