Job inspector agent
This feature is in public preview
job-inspector is an agent definition for background agents that the dlthub-platform toolkit ships. An agent job made from it diagnoses failed job runs. The agent reads the run record, the logs, and the job definition. It follows the traceback into the workspace source, and it follows a missing input back to the job that produces it. It reports the root cause, a classification of the failure, the evidence, and a fix that names the target and the change. It doesn't change code or data.
Set the trigger of the agent job to the jobs that it must watch. A job.fail: trigger selects one job, the jobs in a section, the jobs that have a tag, the pipeline jobs, or all jobs. One agent job inspects every failed job run that its trigger selects. Without trigger=, the agent job runs only when you start it. See Triggers for agents.
Install the toolkit
Make sure that you meet the prerequisites for agent jobs. Then install the toolkit:
dlthub ai toolkit install dlthub-platform
Quick start: inspect failed jobs
Declare an agent job for the job-inspector agent definition in __deployment__.py. Set its trigger to the jobs that it must watch:
"""GitHub ingest workspace with a failure inspector."""
from dlt.hub import run
from github_pipeline import load_commits
inspector = run.agent(
"dlthub-platform:job-inspector",
trigger="job.fail:tag:ingest",
)
__all__ = ["load_commits", "inspector"]
The agent job is named after the agent definition: job_inspector. Run it locally on a job run that failed. Then deploy:
# a single manual run, on a failed run id from `dlthub job runs list`
dlthub local run job_inspector -c failed_run_id=<run_id>
# push the job graph; every failed job tagged "ingest" now starts an inspector run
dlthub deploy
The run log streams to your terminal as the agent works. When the agent run ends, the launcher delivers a job result: status and a Markdown summary at the top level, and the full agent output in result.
Agent inputs
| Input | Meaning |
|---|---|
failed_run_id | Run id of the failed job run to inspect |
failed_job_ref | Job ref of the failed job. If no run id is given, the agent inspects its latest failed run |
Both inputs are optional. The agent uses the first of these that applies:
- If
failed_run_idis set, the agent inspects that job run, whatever its status. - If
failed_job_refis set, the agent inspects the latest failed run of that job. - If a
job.fail:trigger started the agent run, the agent inspects the job run that started it. It reads the id of that run from its own run record. - If nothing names a job run, the agent returns
status: aborted, and itssummarynames the empty inputs. The launcher delivers the job result, and then the job run fails.
An agent run that a job.fail: trigger starts gets both inputs empty and takes step 3. A manual: or schedule: trigger names no run, so a run that you start without an input ends aborted.
If a job run succeeded but loaded no rows, give its run id. The agent follows the empty input back to the job that produces it. To start the inspector on such loads, add a data quality check on the loaded row count and make its job fail when the check fails.
What it reports
| Field | Meaning |
|---|---|
status | succeeded when the agent found the cause, failed when it could not, aborted when it had no run to inspect |
summary | Markdown, in three sections: Diagnosis, Recommendation, Confidence. See Summary format |
root_cause | The cause in one or two sentences. For failed, what is known and what is not |
failed_run_id | The run it inspected, reported as an entity |
failed_job_ref | The job whose run it inspected, reported as an entity |
classification | config, credentials, upstream_data, code, resources, transient, or unknown |
confidence | high, medium, or low. It's low whenever the classification is unknown |
evidence | A source, an excerpt, and a provenance per item. The source says where a reader opens the excerpt, with its line |
proposed_fix | What a person should do next, naming the target and the change. The agent never applies it |
fix_target | The one thing the fix changes: a file path, a config key, a table or resource name, a secret name, or a job ref |
fix_change | The exact value or code change to apply to fix_target, such as cursor_path="ordered_at". Empty when the evidence does not establish it |
open_points | What the agent couldn't verify, one entry each: a tool that failed, a file it didn't find, a value it inferred |
requires_human | Whether a person must act before the job can succeed again. Always true when status is failed |
provenance says where an excerpt comes from: run_log, run_record, pipeline_trace, job_definition, code, configuration, pipeline_data, or comment. A comment is a code comment, a docstring, a README, or a job description: what an author believed. confidence: high never rests on comment evidence alone, and each comment the agent cites gets an entry in open_points.
On the platform, the result appears on the page of the failed job run, because the agent reports that job run as the entity it acted on. The agent writes each job run, job, pipeline, pipeline run, and dataset it names as its entity id, such as `job-runs/<run-id>`. The agent.py that ships with the definition turns those into links to their Web UI pages. It checks each one on the platform first, and leaves an id that the platform does not know as plain text. Read the agent run result shows a full job result.
Summary format
summary holds three headings, each over short bullets:
| Heading | What the bullets answer |
|---|---|
## Diagnosis | The root cause: what failed, where, and why, with the artifact that shows it. For a pipeline job the first bullet names the failing step |
## Recommendation | The next action, written as the instruction itself and starting with its verb (Set, Change, Unpause), one action per bullet |
## Confidence | The limits of the diagnosis: what it rests on, and every entry of open_points |
A person can paste the whole summary into a coding agent. For this reason, each Recommendation bullet names the target and the value. It doesn't tell the reader to investigate.
Data access
The agent definition declares no data axis, so by default the agent reads no data. It lists the tools that restore a pipeline and read its state and rows, and these tools stay off until your agent job grants data: read.
Without data access (default)
The agent reads the run records, the logs, the job definitions, the telemetry, the file list of the uploaded configuration, and the workspace source. It diagnoses missing credentials from the exception: a ConfigFieldMissingException lists every key and provider that dlt tried, and an authentication error names the credential that the destination rejected. When the cause depends on the data in a table, the agent names the table and the query that would settle it in open_points.
On the platform, the job gets no-access, the profile without data access, so no destination credentials reach its process.
With data access
Grant data access when failures often depend on what the destination holds: an incremental cursor that stopped, a pending load package, the schema of a table. The agent then restores the pipeline of the failed run, reads its state and rows on the profile that the agent job runs on, and never writes.
Pass access to the agent job. It replaces the whole block of the definition, so name every axis:
from dlt.hub import run
inspector = run.agent(
"dlthub-platform:job-inspector",
trigger="job.fail:tag:ingest",
access={"local": ["read"], "context": ["read"], "data": ["read"]},
)
- The definition keeps its system prompt, its output, and its
agent.py, so the entities insummarystay links. data: readgives the job theaccessprofile, and the agent restores on that profile. Create the settings files ofaccesswith read-only credentials before you deploy. Without them, the job getsprod. See Profile of an agent job.- Customize an existing agent shows the other settings that an agent job can change.
Skills it uses
The agent definition lists skills that the agent loads when it needs them:
debug-workspace-deployment(dlthub-platform): how to diagnose a deployed job, and which tool answers each questiontroubleshoot-pipeline-runandtroubleshoot-verified-source(init): what a dlt exception or symptom meansdefine-and-debug-jobs-locallyandconfigure-job-profiles(local-workspace): jobs, triggers, and profiles- the debug skills of
rest-api-pipeline,sql-database-pipeline, andtransformations, andoptimize-performance, when your workspace installed those toolkits
Defaults and overrides
The agent definition declares these defaults. The agent job overrides them. Configuration overrides them for one agent run.
| Setting | Default |
|---|---|
limits | max_turns: 30, max_tokens: 1000000. The agent stops reading after its fifteenth turn and writes its answer from what it has |
loop_run_args | retries: 2. pydantic-ai lets the model call a failing tool again two times. After this, the tool call fails, the model sees the failed call, and the agent run continues. claude-agent-sdk ignores this key |
The agent definition declares no trigger and names no model. Give it a model at least as capable as Claude Sonnet 5. See Model and credentials.
Do not give two agent jobs the trigger job.fail:*. job.fail:* selects every batch job in the workspace, agent jobs included. A failed run of agent job A starts agent job B, and a failed run of B starts A. The loop does not stop. An agent run that ends aborted also counts as a failed job run. Use a tag or section selector such as job.fail:tag:ingest, or job.fail:pipeline_name:* to watch every job declared with @run.pipeline.
Narrow the trigger and change the settings on the agent job:
inspector = run.agent(
"dlthub-platform:job-inspector",
trigger="job.fail:tag:ingest",
model="sonnet",
limits={"max_turns": 20},
instructions="focus on the loader step",
)
To change a setting for one agent run, pass it with -c:
dlthub local run job_inspector -c failed_run_id=<run_id> -c agent.model=sonnet
Guardrails
- Reads, never writes. The agent definition declares
local: [read]andcontext: [read]. The agent getsRead,Glob, andGrepover the workspace files. Through the dltHub MCP server, it reads runs, logs, job definitions, telemetry, and the file list of the uploaded configuration, never file contents. - No shell. The agent definition declares no
executeverb. A shell could read the credential files that the file tools refuse, and it could run the inspected job again. - No data unless you grant it. Without
data: read, the agent can't query your destinations. With it, the agent reads on a read-only profile and the system prompt forbids writes. See Data access. - No changes to your workspace. The system prompt forbids changes in addition to the declared access: the agent doesn't edit code, deploy, cancel, or rerun a job. It doesn't recommend changing a tag, a trigger, a schedule, a data location, or an instance size either. It names such a change as a decision for a person.
Next steps
- Background agents shows how to build, test, and deploy agents
- Agent definition reference covers every field of an agent definition
- Toolkits shows the rest of the
dlthub-platformtoolkit - Monitoring and debugging shows how to list runs and read their results