Run job

From sdemyanov/retriever · View interactive version

Run job is an AI agent skill from the GitHub repository sdemyanov/retriever. Use this skill when the user wants to execute a planned Retriever processing run inline or in the background — including natural-language phrasings like "run OCR", "start the image-description job", "kick off the OCR worker", "process the queue", "execute run 42", "resume the stalled run", or "finis

How to use this skill

Skill file

Operates under retriever:routing. If the user's intent actually fits a different tier — another retriever:* skill, a Tier 2 slash, a Tier 3 tools.py subcommand, or (last resort) direct DB access — stop and re-route against the ladder before continuing.

Run Job

Use this skill when the user wants to execute a planned Retriever processing run inline or in the background.

Purpose

The processing DB is the source of truth. This skill decides whether to:

The Python CLI does not own a --background flag.

Inputs

Expected user inputs:

Decision Rule

When unsure, inspect run-status --budget-seconds 35 first.

For long unattended runs, use the supervision hints from run-status:

If should_schedule_wakeup is true, keep a thread wake alive on the suggested interval (currently 60 seconds). Stop scheduling wakes when it becomes false.

Unattended Continuation

For unattended long runs, use a thread heartbeat automation attached to the current conversation.

When to create or update it:

How to configure it:

When to stop it:

Do not build a second supervisor inside Python. The heartbeat is the wake mechanism; the skill remains the orchestrator.

Bounded Claude Code Execution

Claude Code command calls may be interrupted around 45 seconds. Prefer the

bounded facade:

python3 skills/tool-template/tools.py run-job-step <workspace> --run-id <RUN_ID> --budget-seconds 35

run-job-step performs exactly one safe orchestration step:

If the result contains a non-empty batch, process those items and call complete-run-item or fail-run-item for each one. Then call run-job-step again if the run still needs work.

Execution Loop

Whether running inline or in a subagent, use the same small-batch loop.

The low-level orchestration command is:

  1. prepare-run-batch --run-id ... --claimed-by ... --budget-seconds 35 --launch-mode ... [--worker-task-id ...] [--max-batches ...] [--limit ...]

It returns:

Read worker.next_action:

If worker.stop_reason is canceled, exit immediately.

Batch Processing

For each item in batch:

  1. Read batch[i].context.execution.task_prompt
  2. Use the provided input payload to perform the capability work in-turn
  3. Use batch[i].context.execution.completion_template as the exact shape for completion
  4. Call complete-run-item ... or fail-run-item ...

Use these supporting commands during the loop:

Use small batches only. The worker hints expose:

Cancellation

Background Mode

In background mode:

The main conversation should use run-status to inspect progress. Do not stream per-document OCR or extraction output back into chat.

Use a few durable workers, not one subagent per document.

On each wake:

  1. Start with run-status.
  2. If run.supervision.should_schedule_wakeup is false:
  1. If run.supervision.recommended_action is finalize_ocr or finalize_image_description:
  1. If run.supervision.recommended_action is spawn_background_worker:
  1. If run.supervision.recommended_action is wait:
  1. If run.supervision.recommended_action is stop:

The agent may choose the exact worker count dynamically, but it must stay within the runtime bounds from run.supervision.

If prepare-run-batch returns next_action = handoff, stop this worker with finish-run-worker --worker-status stopped and let a fresh subagent continue from the DB state.

Inline Mode

In inline mode:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.