Documentation / guides
Overview
Register bounded auxiliary inference used by Harness facilities such as compaction and permission review.
A Hustle is an immutable, bounded auxiliary inference definition. Harness facilities use registered definitions for focused work such as transcript compaction or permission review. It is not a conversational Loop, a delegated agent, or a general task queue.
When to use
Application code configures a Hustle through the facility that needs it. There
is no public generic execution method for an arbitrary definition. Register
immutable definitions on the Rig, then invoke a supported operation such as
Session.Compact.
Proof: Hustle definition boundary and session contract tests.
Configure a Hustle
compactor, err := hustle.Define(
hustle.WithName("context.compact"),
hustle.WithParticipation(hustle.ParticipationBlocking),
hustle.WithTimeout(5*time.Second),
hustle.WithLimits(hustle.Limits{
InputBytes: 1024 * 1024,
OutputBytes: 1024 * 1024,
}),
hustle.WithCurrentLoopModel(),
hustle.WithSystemPrompt("Summarize the earlier conversation.", "v1"),
hustle.WithPolicyRevision("v1"),
)
if err != nil {
return fmt.Errorf("define compaction hustle: %w", err)
}
runtime, err := rig.Define(
rig.WithLoops(assistant),
rig.WithPrimers("assistant"),
rig.WithSessionStore(sessions),
rig.WithHustles(compactor),
rig.WithHustleLimits(rig.HustleLimits{
BlockingConcurrent: 1, BlockingQueued: 2,
BackgroundConcurrent: 1, BackgroundQueued: 2,
AuditTimeout: time.Second, FinalizationTimeout: time.Second,
WorkerDrainTimeout: time.Second,
}),
)
if err != nil {
return fmt.Errorf("define rig: %w", err)
}
WithCurrentLoopModel resolves the originating Loop’s current model for each run. WithNamedInference instead freezes a dedicated client and model into the Hustle definition.
Proof: definition options and Rig Hustle registration.
Lifecycle
Blocking and background definitions use separate bounded lanes. A supported
facility binds the definition, validates input, owns a RunID, persists an
internal HustleStarted record, admits the run, resolves inference, validates
bounded output, persists exactly one internal terminal event, and finalizes
once. Session shutdown closes admission, cancels active work, drains owned
invocations, and only then tears down loop runtimes and resources.
Proof: Hustle runtime ownership and lifecycle tests.
Restore and observation
HustleStarted, HustleCompleted, and HustleFailed are internal-visibility
audit records. Correlate them by RunID through the internal audit path, not
an ordinary public Session event stream. Restore folds those records but does
not recreate an interrupted queue, worker, request, or finalizer. An unmatched
start is retained as interruption evidence and the restored Session receives a
fresh controller.
Proof: Hustle audit events, restore folding, and restore tests.