Agent definition reference
This feature is in public preview
This page is the reference for agent definitions and agent jobs. Background agents shows the common tasks with one example each. Installed toolkits ship verified agent definitions, such as the job inspector agent in the dlthub-platform toolkit.
Terms
| Term | Definition | Where it lives |
|---|---|---|
| Agent definition | System prompt plus a declaration of the inputs, the output, the MCP feature groups, the skills, the rules, and the access of the agent | AGENT.md file, or a decorated Python function |
| Agent loop | Framework that runs the model turn by turn: pydantic-ai (default) or claude-agent-sdk | Selected with loop= on run.agent or agent.loop in configuration |
| Agent job | Definition plus the settings for your workspace: model, limits, trigger, instructions, loop | run.agent(...) in __deployment__.py |
| Agent run | Execution of the agent job. It receives inputs and returns an agent output and an agent trace | Started by a trigger, dlthub local run, dlthub run, or the Web UI |
| Access axis | Area of the workspace that access covers: local for the files and the shell, data for the data in your destinations, context for runs, logs, job definitions, and telemetry | Key of access in the agent definition |
| Verb | What the agent can do on an axis: local takes read, write, execute, network; data takes read, write; context takes read. all grants every verb of its axis | Listed under the axis in access |
An AGENT.md is better for an agent definition that is only a system prompt plus declarations, for a definition that a toolkit ships, and for a definition that people who don't write Python maintain. A Python function is better when the schemas come from Python types, or when code runs around the loop. To change the access, tools, skills, rules or settings of an installed AGENT.md, you need neither: run.agent takes them as arguments. See Agent job arguments.
Agent definition in an AGENT.md file
dlthub ai toolkit install copies the agent definitions of a toolkit to .claude/dlthub/agents/<toolkit>/<name>/AGENT.md (.cursor/dlthub/agents/ or .agents/dlthub/agents/ for the other hosts), so two toolkits can ship an agent with the same name. Coding agents don't scan this folder for their own subagents. You can also keep an AGENT.md in any folder of the workspace and refer to it by its path.
The YAML frontmatter holds the declarations and the Markdown body is the system prompt. Only the body is required. A file with no frontmatter is a working agent definition, named after its folder. The example below is a shortened version of the job-inspector definition:
---
name: job-inspector
description: Inspects a failed job run and reports a diagnosis with a proposed fix. Read-only.
tools: [jobs, logs, telemetry, config, restore_pipeline, pipeline] # feature groups of the dltHub MCP server
skills: # loaded when the agent needs them
- dlthub-platform:debug-workspace-deployment
- init:troubleshoot-pipeline-run
access: # what the agent may read, write, or run
local: [read] # read | write | execute | network
context: [read] # runs, logs, job definitions, telemetry
# no `data`: restore_pipeline and pipeline serve nothing
# until a deployment grants data: read
inputs:
type: object
properties:
failed_run_id:
type: string
description: run id of the failed job run to inspect
entity_type: job-runs # this input names a workspace entity
failed_job_ref:
type: string
description: job ref of the failed job; its latest failed run is inspected when no run id is given
entity_type: job
required: []
output:
type: object
properties:
status:
type: string
enum: [succeeded, failed, aborted]
description: Outcome of your task, as defined in your system prompt
summary:
type: string
description: Markdown. What you accomplished, or what blocked you when `status` is `aborted`
root_cause:
type: string
description: The cause in one or two plain sentences
failed_run_id: # the run actually inspected, reported as an entity
type: string
entity_type: job-runs
classification:
type: string
enum: [config, credentials, upstream_data, code, resources, transient, unknown]
description: The kind of failure, as defined in the "Classification" section of your system prompt
confidence:
type: string
enum: [high, medium, low]
description: How well the evidence supports the classification. `low` whenever the classification is `unknown`
evidence:
type: array
items:
type: object
properties:
source: { type: string } # where a reader opens the excerpt, with its line
excerpt: { type: string }
provenance:
type: string
enum: [run_log, run_record, pipeline_trace, job_definition, code, configuration, pipeline_data, comment]
required: [source, excerpt, provenance]
proposed_fix:
type: string
description: What a human should do next, naming the target and the change. You never apply it
requires_human:
type: boolean
required: [status, summary, root_cause, classification, confidence, evidence, requires_human]
defaults: # the job and the run may override all of these
limits: { max_turns: 30, max_tokens: 1000000 }
loop_run_args: { retries: 2 }
---
You are a job inspector for a dltHub Platform workspace. You run unattended, seconds
after a job failed. Explain the failure. Do not repair it.
Inputs: run id '{{ failed_run_id }}', job ref '{{ failed_job_ref }}', trigger
`{{ run_context.trigger }}`. Any may be empty. Use the first of these that applies:
...
| Field | Meaning |
|---|---|
name | Name of the agent definition. Optional, defaults to the folder name |
description | What the agent does and when to run it. Shown in the Web UI |
tools | Feature groups of the dltHub MCP server the agent receives |
skills, rules | <toolkit>:<name> references to components the agent uses, or workspace-relative paths |
access | What the agent asks to read, write, run, or reach, per access axis: local, data, context |
inputs | JSON Schema of the inputs. Each input is a job configuration key |
output | JSON Schema of the output. status and summary are part of it in every agent definition |
defaults | Settings that the agent job and the run can override: model, limits, loop_run_args, execute |
| body | System prompt, a template over inputs |
dlt checks the frontmatter when it reads the file. An unknown field, a value of the wrong type, or invalid YAML fails with the file path and the field. tools, skills, and rules take one name or a list.
Input schema
inputs is a JSON Schema. Every property becomes a configuration key of the job. You can set it in three ways: with -c failed_run_id=... on the command line, under [jobs.<section>.<job>] in config.toml or the environment, or with a run argument that the trigger carries. Values are typed: -c depth=3 resolves to an int when the schema declares one.
The body refers to inputs as {{ name }}. It can also refer to the run itself:
| Placeholder | Value |
|---|---|
{{ run_context.trigger }} | The trigger that started the run, such as job.fail:jobs.ingest.load or manual: |
{{ run_context.run_id }} | The id of this run |
{{ run_context.refresh }} | Whether the run carries the refresh signal |
{{ run_context.profile }} | The workspace profile that the job runs with |
{{ run_context.interval_start }}, {{ run_context.interval_end }} | The interval of a job with a schedule or an interval trigger |
The loop renders the placeholders before the first turn. Only the body is rendered: a {{ }} in a rule or a skill reaches the model as written.
- A required input with no value fails the run like any missing job argument.
- An optional input with no value renders as empty text. The body must say what to do then, and when to abort.
- A placeholder that names an undeclared input produces a warning when the run starts, and the agent trace lists it under
unresolved_placeholders. inputs.promptis refused. Put the task in the body.
Entity-typed inputs and outputs
An input that names a workspace object carries entity_type: job-runs, job, pipeline, dataset, or workspace. The agent receives the bare id (a run id, a job ref, a pipeline name). Declaring the type does two things:
- The job run reports the entity in its job result, so the run shows up on that entity's page in the Web UI.
- The first entity-typed input becomes
expose.object_inputin the deployment manifest. The Web UI reads it to link agent jobs to entities. On the row of a job run, it opens the latest agent run that investigated that run.
If the agent can act on a different entity than the one it received, declare the same name with entity_type on an output property. The output value overwrites the input of the same name. As a result, an inspector that found a run from a job ref reports the run that it inspected.
Output schema
output is a JSON Schema of what the agent returns. Two properties are part of every agent's output and dltHub adds them when the definition leaves them out:
| Property | Meaning |
|---|---|
status | succeeded or failed, as your system prompt defines them, or aborted when the agent can't do the task at all |
summary | Markdown. What the agent accomplished. For aborted it becomes the text of the exception that fails the run |
dltHub replaces any declaration of status or summary that differs from the standard one. The model receives the whole output schema, every description and enum included. The schema describes the shape of the answer. The body says what each value means and when to pick it.
- Declare
statusandsummaryin the file so it shows the whole contract, and leave them as they stand. - Put a domain outcome in a field of its own, so a data-quality agent returns a
verdictandstatuskeeps its meaning. - Give every property a
type, an enum included. Give a description to each field whose name doesn't explain it.
Keep the schema small. A large one can stop a platform run before the container launches, with no error, no logs, and no start time on the run record. Stay under about 8,000 characters of JSON: flatten nested models and drop the fields the summary already covers.
The schema reaches the model as declared, except that entity_type moves into $comment. Anthropic's structured output rejects minimum, maximum, minLength, and maxLength, a property with enum and no type, and more than 24 optional properties. Put numeric bounds in the field description instead.
This data-quality agent reports a verdict on the run it checked:
output:
type: object
properties:
verdict:
type: string
enum: [pass, warn, fail]
description: pass when every check passed, warn when only soft checks failed, fail otherwise
checked_run_id:
type: string
entity_type: job-runs # travels to the model in `$comment`
rows_checked:
type: integer
description: How many rows you read, between 1 and 1000000 # a bound belongs here, `minimum` is rejected
required: [status, summary, verdict]
Summary structure
summary is Markdown, rendered on the run page. By default it carries three headings, each over short bullets:
| Heading | What the bullets answer |
|---|---|
## Diagnosis | The root cause: what failed, where, and why. One bullet quotes the evidence line carrying it |
## Recommendation | The next action: the target and the change, written as the instruction itself |
## Confidence | The limits of the diagnosis: what it rests on, and every entry of open_points |
If your agent reports something else, declare your own headings in the body. Show the headings as a literal block in the body: a model that only reads a description of the shape tends to write a paragraph.
Access declaration
access is what the job declares it needs to run. The platform grants the job no more than it declares, and the profile of the job gives the credentials.
access is declared per axis. Each axis takes one verb or a list of verbs, and an axis that you leave out declares no access. With no access at all, the agent gets no file tools and no shell. If tools starts an MCP server, the server serves only the tools that need no access, such as the toolkit catalog.
| Axis | Verbs | Grants |
|---|---|---|
local | read | Read, Glob, Grep on the workspace files |
write | Write, Edit | |
execute | Bash (PowerShell on Windows), and on pydantic-ai also RunPython, in the workspace | |
network | WebFetch, WebSearch | |
data | read, write | Workspace data through the data and restore tools of the MCP server. The tools need read, and no tool needs write yet. The SQL tool runs one read-only statement, whatever verbs data declares |
context | read | Runs, logs, job definitions, and telemetry through the MCP server. dlt refuses write, execute, and deploy when it reads the agent definition |
all is shorthand for every verb on an axis. local maps to the same toolset on both loops, under the names Claude Code uses. Credential files (*secrets.toml, .env, .env.*) are never readable by a file tool, whatever verbs local declares. The job runner carries no curl, so an agent with execute makes an HTTP request from Python with urllib.
A feature group in tools whose access the definition leaves out serves nothing until the job grants it. An agent definition can list the pipeline and restore_pipeline groups and leave data to the workspace: an agent job that declares access={..., "data": ["read"]} turns them on. The job-inspector definition does this, see Data access.
The declaration is a request that the runtime grants as far as it can. If a loop has no tool for a granted verb, the run proceeds with the tools it has. The agent trace of each agent run lists the tools that the loop wired.
Model providers can give a model tools that run on their own servers, on any loop and with any model. access doesn't control these tools. For example, pydantic-ai gives recent Anthropic models the web search and fetch tools of Anthropic for network, and with them a code execution sandbox on the servers of Anthropic. The sandbox has no access to the workspace, its files, or its credentials.
Write the policy into the body as well. "You are read-only" in the system prompt helps the model understand its role, and the access block enforces it for the MCP tools. local: execute is the exception. The shell runs with the credentials of the job, and nothing limits what it does with them. An agent with execute and data access needs a rule in the body: never write data.
Profile of an agent job
access is what a job declares it needs to run: the access of the agent definition, or the access= argument of the job when it has one. A profile gives the credentials that the job process holds. A deployment gives an agent job that declares no profile the default profile of the environment for the data access that its access declares:
data in access | Profile in the prod environment |
|---|---|
| left out | no-access, a profile without data access |
read | access |
write | prod |
An agent job that declares data: write and runs on the access profile can't write, because its credentials can't. The profile covers profile-scoped configuration: prod.secrets.toml, prod.config.toml, and a variable set with dlthub variable set --profile prod. A variable set with --workspace has no profile, and it reaches the job on every profile. A secret that an agent must not get belongs in a profile scope. dlthub variable list prints the scope of each one. dlthub local run uses the active profile for every job.
To give an agent job a profile of its own, declare the profile on the job. This agent definition declares data: read, and the profile gives read data access:
care_inspector = run.agent(
"agents/customer_care",
trigger="job.fail:tag:care",
require={"profile": "sensitive-access"},
)
A declared profile wins, prod included. A strict environment refuses it only when the job declares other data access in data, or when the profile has no settings files. So nothing stops require={"profile": "prod"} on an agent job without data. Don't give an agent job the production profile. An agent job runs unattended, and a model decides what to do. Work that needs production write credentials belongs in a pipeline or a plain job that a person wrote and reviewed.
Before you run an agent job with data: read, make sure that the destination credentials in your access profile are read-only at the destination itself. Use a read-only database role, or a storage key without write permission. dltHub doesn't check what the credentials of a profile can do. Create the settings files of access before you deploy. Without them, an agent job that declares data: read and no profile gets prod. Settings files covers where each profile's credentials live.
A deployment refuses a profile that does not belong to its environment. A local profile such as dev, a profile of another environment or a typo stops dlthub deploy. The error shows the dlthub profile add command that adds the profile. On dlthub local run, the declared profile only produces a warning: the run uses the active profile and reports the mismatch.
Tools, skills, and rules
tools lists feature groups of the dltHub MCP server: workspace, pipeline, toolkit, secrets, context, on the platform jobs, logs, telemetry, config, restore_pipeline, plus groups that other plugins contribute. The agent receives exactly the groups listed, and within a group only the tools its access covers. Without tools no server is started.
skills and rules reference components of an installed toolkit as <toolkit>:<name>, or a workspace-relative path such as .claude/skills/my-skill/SKILL.md.
- Skills load on demand, on both loops. The model sees the name and the description of each skill and loads its body when it needs it, with the path of the skill folder. With
local: read, it can read the files next to theSKILL.md. - Rules are inlined into the system prompt on both loops, so a rule costs its full text on every turn.
- The agent receives only the listed components. dlt does not load other skills and rules installed in the workspace, including the
.claude/rulesfolder. If a reference does not resolve, dlt logs an info message and skips it.
Defaults for the agent job
defaults holds the values that apply when the agent job and the run's configuration don't override them. State a requirement in the body, since any default can be overridden.
defaults:
model: sonnet # alias, or provider:model
limits: {max_turns: 30, max_tokens: 1000000}
loop_run_args: {retries: 2} # passed to the framework
execute: {timeout: 10m, concurrency: 3}
execute sets the timeout and concurrency of the agent job. The execute= argument of the job overrides each key it sets. An agent job runs up to 5 runs at once unless the job or defaults.execute sets concurrency. Set concurrency: null for no limit.
The order is the loop's own default, then defaults, then the job's arguments, then configuration. limits, loop_run_args, and execute merge key by key, so limits={"max_turns": 20} on the job keeps the max_tokens of the definition. A turn is one model request. max_tokens counts input tokens, cache reads and writes included, and output tokens. The run stops after the turn that passes it. Without a limit, pydantic-ai stops at 50 turns and claude-agent-sdk at 30, with no token limit.
access, tools, skills, and rules are declarations, not defaults. They don't merge: an argument for one of them, on run.agent or on a decorated function, replaces the list of the definition as a whole. See Agent job arguments.
Leave model out of a definition you ship in a toolkit. The user who installs it can be on Anthropic, OpenAI, Azure, or Google, and can't always reach the model that you name. Write in the body which models you wrote the system prompt for, for example "at least as capable as Claude Sonnet 5".
System prompt body
The body is the system prompt. Write it as you would a skill, for a reader who has the tools and needs the context. Platform knowledge belongs in the referenced rules and skills. Keep the body under about two hundred lines and cover these points:
- State the role in two sentences, including that the agent runs unattended.
- Define
succeeded,failed, andabortedfor this agent. The output schema lists the three values but says nothing about when each applies. Under structured output the model leans towardssucceededwhen unsure, so spell out what counts as a failure. - Say what to do with each input, and with its absence. Name the fallbacks in order and the point at which the answer is
aborted. - Give the first steps concretely. Which tool to call first, what to read, what to look for. Give a page size for every list tool.
- Write constraints as rules, for example "Never edit code, never deploy, never rerun a job".
- Define every enum the output declares. Say what
unknownorlowmeans and that reporting it is a legitimate outcome. - State the headings
summarymust carry and the shape of its bullets. See Summary structure. - Say when to stop reading and write the answer, for example "Stop reading after your fifteenth turn". A run that reaches its limit returns nothing.
The model also receives the rules, the names and descriptions of the skills, the output schema, the tools, and the paths of the workspace and the temp folder. The body doesn't need to repeat them. The user turn of each run is the job's instructions, or "Go ahead" when none are set.
Agent code in agent.py
An agent folder can have an agent.py next to its AGENT.md. dlt imports it when a job that references the agent definition runs, and calls two functions from it when they are defined:
| Function | Called with | Its return value |
|---|---|---|
validate_input(inputs) | the inputs of the run as a dict, before the loop starts: each declared input that has a value, the run arguments and the call arguments, and run_context (see below) | replaces the inputs. Return None to keep them unchanged |
validate_output(output) | the agent output as a dict, after the loop ends: status, summary and the declared output fields | replaces the output. Return None to keep it unchanged |
run_context holds run_id, trigger, refresh, profile, and run_args, and on a job with an interval also interval_start and interval_end. Return the whole dict, not only the keys that you change.
Keep your agent.py next to an agent definition of your own. An agent definition that a toolkit installed may ship its own agent.py, and updating the toolkit replaces it. Validate inputs and outputs with agent.py shows an example.
- An exception from either function fails the job run. To end a run on purpose without calling the model, raise
JobAbortedExceptionfromvalidate_inputwith the agent output to deliver. The run is reported asaborted, andvalidate_outputisn't called. - A job that also passes
inputs_validatororoutputs_validatorgets both: the functions inagent.pyrun first, then the job's own on their result. - dlt runs
agent.pyonly for a job that references the agent definition, asrun.agent("<toolkit>:<agent>")or by path. A decorated function drives the loop itself. dlt never importsagent.pywhen it generates the deployment manifest.
Helper modules and module state
The agent folder is imported as a package, so agent.py can import the files next to it relatively. Two agents can each ship a checks.py without a conflict. agent.py is imported afresh for every run, so a module variable can carry what validate_input found to validate_output within one run:
# agents/run-auditor/agent.py
from .checks import prepare, finalize
_prep = None
def validate_input(inputs):
global _prep
_prep = prepare(inputs["run_context"])
return {**inputs, **_prep.prompt_inputs}
def validate_output(output):
return finalize(output, _prep)
Agent definition as a Python function
A decorated function doesn't need an AGENT.md or a toolkit. Its docstring is the system prompt. Its parameters with a default or with dlt.config.value are the inputs. Its return type is the output. The decorator arguments are the agent job's settings, and the body drives the loop it finds in run_context["ai_loop"].
Write the docstring as a system prompt. The model gets it on every agent run with its placeholders rendered, as it gets an AGENT.md body. The points in System prompt body apply to it. The function body controls the loop, and the model doesn't read it.
from typing import Annotated, List, Literal
import dlt
from dlt.common.typing import NotRequired
from dlt.hub import run
class CrashReport(run.TAgentOutput):
"""Diagnosis of one failed job run."""
classification: Annotated[
Literal["config", "credentials", "code", "upstream_data", "unknown"],
run.Doc("What kind of failure it was"),
]
confidence: Literal["high", "medium", "low"]
evidence: NotRequired[List[str]]
@run.agent(
access={"local": ["read"], "context": ["read"]},
tools=["telemetry"],
skills=["dlthub-platform:debug-workspace-deployment"],
trigger="job.fail:tag:ingest",
limits={"max_turns": 30},
)
async def crash_inspector(
failed_run_id: Annotated[str, run.Entity("job-runs")] = dlt.config.value,
depth: int = 2,
run_context: run.TJobRunContext = None,
) -> CrashReport:
"""Inspects a failed job run and reports a diagnosis.
You run unattended, seconds after a job failed. Explain the failure; do not repair it.
Investigate run '{{ failed_run_id }}' from `{{ run_context.trigger }}`, going
{{ depth }} runs back. Return `aborted` when the inputs give you nothing to inspect.
"""
loop = run_context["ai_loop"]
report = await loop.run(inputs={"failed_run_id": failed_run_id, "depth": depth})
if loop.trace["total_tokens"] > 800_000:
report["summary"] += "\n\n_Investigation was expensive; consider narrowing the trigger._"
return report
| In Python | In the agent definition |
|---|---|
| Function name | name of the agent job |
| Docstring | System prompt, placeholders included. Its first line is the description |
Parameters with a default or dlt.config.value | inputs, and so the job's configuration: -c failed_run_id=... fills them, typed. A parameter without a default is not an input |
Annotated[str, run.Entity("job-runs")] | Entity-typed input |
dlt.config.value default | Required input |
run_context parameter | Passed by the launcher, not declared as an input |
Return type deriving from run.TAgentOutput | output. run.Doc(...) on a field is its description, and the class docstring describes the whole output |
access=, tools=, skills=, rules= | Matching AGENT.md fields |
model=, limits=, loop_run_args=, execute= | defaults in an AGENT.md |
instructions=, trigger=, loop= | Agent job settings. An AGENT.md has no field for them |
dlt builds the schemas from the same configuration spec that injects the arguments, so an input is required exactly when configuration requires it. The schemas cover Optional, Literal, enums, lists, dicts, dates, nested TypedDicts with NotRequired keys, and configuration specs, including credentials and specs nested in other specs. A credentials argument accepts its fields or a connection string, and secret values are marked writeOnly. A TypedDict's docstring becomes the description of its schema, so write it for the model. The return type must be run.TAgentOutput or a TypedDict that derives from it. An agent definition given inline to run.agent may also give output as a pydantic model class. The function can be def or async def. loop.run() adds run_context to the inputs that you pass, so placeholders such as {{ run_context.trigger }} render. A function can run the loop twice, or not run it.
A function can also drive an installed agent definition. Pass it as agent=. The decorator arguments override the fields of the definition. The function overrides them in turn:
- A docstring replaces the body.
- The parameters of the function decide which inputs exist. For each parameter, what the signature says wins, and the definition fills in what the signature leaves out: the description,
entity_type, other attributes, and the type when the parameter has no annotation. Inputs of the definition that the function doesn't take are dropped. The inputs of the agent job in the deployment manifest,expose.object_inputincluded, come from the same merge. - A return type that derives from
run.TAgentOutputreplacesoutput. Without a return type, the definition'soutputstays.
@run.agent(
agent="dlthub-platform:job-inspector",
loop="claude-agent-sdk",
)
async def inspect(
failed_run_id=dlt.config.value,
failed_job_ref: str = None,
run_context: run.TJobRunContext = None,
):
return await run_context["ai_loop"].run(
inputs={"failed_run_id": failed_run_id, "failed_job_ref": failed_job_ref}
)
The function has no docstring and no return type, so the system prompt and the output of the definition stay. failed_run_id has no annotation, so it takes its type, its description, and entity_type: job-runs from the definition. failed_job_ref declares its type and takes its description and entity_type: job from the definition.
The function leaves access, tools, skills, and rules out here, so the definition's own lists stand. Passing one of them replaces the definition's list rather than adding to it, so an access argument has to name every axis the agent needs. A function isn't needed for that: run.agent("dlthub-platform:job-inspector", access=...) does the same, and the definition's agent.py still runs.
Agent job arguments
run.agent(...) declares a job from an agent definition. The first argument is the agent definition, in one of three forms:
- a
<toolkit>:<agent>reference to an installed agent definition - a workspace-relative path to a folder that holds an
AGENT.md - a
TAgentSpecdict, declared inline
from dlt.hub import run
inspector = run.agent(
"dlthub-platform:job-inspector",
trigger="job.fail:tag:ingest",
model="sonnet",
limits={"max_turns": 20},
instructions="focus on the loader step",
)
The job is named after the agent definition (job-inspector becomes job_inspector) in the declaring module's section. Every argument overrides the matching entry of the definition's defaults. The job takes no trigger from the agent definition: an agent job without trigger= runs only when you start it.
You can call the agent job in process, for example in a script or a test. An agent job without a function returns a coroutine, so await it: await inspector(failed_run_id="..."). It takes its inputs as keyword arguments only. The call returns the agent output, not the job result, and sends nothing to the platform.
access, tools, skills, and rules aren't defaults. An argument for one of them replaces what the agent definition declares, as a whole: tools=["jobs"] leaves only jobs, and an access that leaves out an axis grants nothing on that axis. Leave the argument out to keep what the agent definition declares. A decorated function that drives an agent definition (agent=) replaces them the same way.
inspector = run.agent(
"dlthub-platform:job-inspector",
access={"context": ["read"]},
tools=["jobs", "logs"],
)
| Argument | Meaning |
|---|---|
instructions | First user message of each run. Use it for the task at hand. The system prompt describes the agent |
access, tools, skills, rules | Replace what the agent definition declares, each as a whole. See Access declaration |
model | provider:model id such as anthropic:claude-sonnet-5, or an alias. See Model and credentials |
limits | max_turns and max_tokens per run. The loop ends the run when either is exhausted |
loop | "pydantic-ai" (default) or "claude-agent-sdk". See Agent loops |
loop_run_args | Arguments passed to the framework, merged over the definition's defaults. On pydantic-ai, retries sets how often the model retries a failing tool call, 0 by default. After that, the call fails and the run continues |
verbosity | How much of the run is printed, 0 to 2, 1 by default. See Read the agent run result |
emojis | Marks tool calls, results and the outcome in the printed run with emojis. true by default, false prints labels and arrows |
inputs_validator | Called with the resolved inputs, run_context included, before the run. Its return value replaces the inputs and None keeps them. Use it to derive an input such as a run id from a job ref |
outputs_validator | Called with the agent output after the run. Its return value replaces the output and None keeps it |
name, section | Job name and configuration section, as on every job |
execute | timeout and concurrency. Keys you leave out come from defaults.execute of the agent definition. An agent job runs up to 5 runs at once (other jobs 1). concurrency: None removes the limit |
retry | Retry policy stored as execute.retry. An integer sets max_retries. See Retries |
trigger, expose, require, spec | Standard job options. See Triggers and scheduling and Job configuration |
Only an agent job without a function takes the two validators. On a decorated function, run.agent raises TypeError. When the agent definition has its own agent.py, its functions run first and the job's validators run on their result.
Triggers for agents
Agent jobs take every trigger other jobs take. Two string triggers react to the outcome of other jobs in the workspace: job.fail: and job.success:. After the colon you write which jobs to watch, as a job ref or as a selector.
Job refs
A job ref is the name the platform gives one job. It is built from where the job is declared, so you can read it off the source. This file declares two jobs:
# github_pipeline.py
from dlt.hub import run
@run.pipeline("github", expose={"tags": ["ingest"]})
def load_commits():
...
@run.job()
def check_commits():
...
Deployed, they are jobs.github_pipeline.load_commits and jobs.github_pipeline.check_commits:
| Part | Where it comes from |
|---|---|
jobs | Fixed prefix on every job ref |
github_pipeline | The section: the file the job is declared in, without the .py |
load_commits | The decorated function's name |
The section is the filename. The pipeline name, "github" here, never appears in the ref. You can set the section with section="ingest" on the decorator. Without it, a job written inline in __deployment__.py gets the section __deployment__. dlthub job list prints the refs of a deployment.
Selectors
A selector matches a set of jobs at once. It takes the same forms dlthub job trigger takes:
| Selector | Matches |
|---|---|
jobs.github_pipeline.load_commits | That one job |
jobs.github_pipeline.* | Every job declared in github_pipeline.py |
tag:ingest | Every job tagged ingest, wherever it is declared |
pipeline_name:* | Every job declared with @run.pipeline |
pipeline_name:github | Every @run.pipeline job that runs pipeline github |
batch: | Every batch job |
* | Every job in the workspace |
So trigger="job.fail:tag:ingest" starts the agent job whenever a job tagged ingest fails, and trigger="job.success:jobs.github_pipeline.load_commits" starts it when load_commits succeeds. pipeline_name:* is a safe way to watch every pipeline in the workspace: unlike * it never matches an agent job, because only @run.pipeline declares a pipeline.
When retries are configured for the job, any on-failure follow-up will only run after the final attempt, if it keeps failing. See Retries for more details.
A selector expands at deploy time to a follow-up trigger per matching job. The declaring job itself and interactive jobs are excluded. dlthub deploy --show-manifest prints the concrete triggers a selector expanded to. A manual run arrives with a manual: trigger and only the inputs that it was given, so the system prompt must say what to do when an input is empty. dlt adds the manual: trigger itself, so passing trigger.manual() raises InvalidTrigger: manual: triggers are added automatically.
Check what a wide selector matched before you deploy a second agent job. job.fail:* and job.fail:batch: match every batch job in the workspace, agent jobs included. Don't let two agent jobs watch job.fail:*. A failed run of one starts the other, and the two jobs start each other until you archive one. The declaring job is excluded, so an agent job doesn't start on its own failure. Scope each agent job with a tag, a section or a pipeline selector, such as job.fail:tag:ingest or job.fail:pipeline_name:*. Excluding agent jobs from wide selectors is planned.
Run configuration
Each trigger of the agent job produces an agent run. You can also start a run manually:
dlthub local run job_inspector -c failed_run_id=<run_id> # locally
dlthub run job_inspector -f # on the platform
-c is a local flag. dlthub run does not take it, and a workspace variable holding an input key does not reach a remote run either. A remote run takes its inputs from the trigger that started it, or from the job's config.toml as deployed.
Inputs and agent settings are job configuration in the section of the job. The same keys work on the command line, in config.toml, and in the environment:
| What | Key | Example |
|---|---|---|
| Declared inputs | jobs.<section>.<job>.<input> | -c failed_run_id=... |
| Instructions, model, limits, loop, verbosity, emojis | jobs.<section>.<job>.agent.* | -c agent.instructions="explain, do not fix", -c agent.max_turns=10, -c agent.verbosity=2, -c agent.emojis=false |
# .dlt/config.toml
[jobs.__deployment__.job_inspector]
failed_job_ref = "jobs.github_pipeline.load_commits"
[jobs.__deployment__.job_inspector.agent]
model = "sonnet"
max_turns = 20
verbosity = 0
Each source overrides the ones before it: the loop default, the definition's defaults, the run.agent argument, the run's configuration. limits and loop_run_args merge key by key, so setting max_turns keeps the max_tokens of the source below. dlthub -v local run <job> sets agent.verbosity to 2 for that run, unless -c agent.verbosity=... sets it. Ctrl-C on a local run, or a stop on the platform, ends the run at the next turn.
dlthub deploy ships the job graph and the agent definitions with the rest of the workspace. A selector trigger expands at deploy time, so a job.fail: agent job starts watching the jobs it matches as soon as the deployment lands. See Deployments.
Model and credentials
model is a provider:model id in the naming pydantic-ai uses, or an alias for one:
| Provider | model | Alias |
|---|---|---|
| Azure OpenAI | azure:<deployment name> | none |
| Anthropic | anthropic:claude-sonnet-5, claude-opus-5, claude-haiku-4-5, claude-fable-5 | sonnet, opus, haiku, fable |
| OpenAI | openai:gpt-5.5, openai:gpt-5.4-mini, openai:gpt-5.4-nano | gpt, gpt-mini, gpt-nano |
google:gemini-3.5-flash, google:gemini-3.1-pro-preview | gemini, gemini-pro |
If the job, the agent definition, and the configuration name no model, the loop uses sonnet. The agent definitions that a toolkit ships name no model, so the workspace that deploys the agent job selects the model for its provider.
Azure OpenAI addresses a deployment on your own endpoint, not a shared model. It has no alias, and it needs api_url and api_version together with the model and the key. The claude-agent-sdk loop runs Anthropic models only, so naming it in a workspace whose key is Azure or Google breaks the run.
The model and its key are configuration, resolved like any other dlt setting. The agent section applies to every agent job of the workspace, and jobs.<section>.<job>.agent to one job, which wins over agent. The model goes in config.toml and the key in secrets.toml:
# .dlt/config.toml
[agent]
model = "anthropic:claude-sonnet-5"
# one job with a model of its own
[jobs.__deployment__.job_inspector.agent]
model = "anthropic:claude-opus-5"
# .dlt/secrets.toml
[agent]
api_key = "sk-ant-..."
Azure OpenAI takes all four keys, api_url and api_version in config.toml:
# .dlt/config.toml
[agent]
model = "azure:my-gpt-deployment"
api_url = "https://my-resource.openai.azure.com"
api_version = "2024-10-21" # the api-version your deployment serves
Azure is the only provider pydantic-ai gives api_version. Other providers ignore it and log a warning.
Put the key in the shared .dlt/secrets.toml, not in the secrets file of a profile. An agent job without data runs on no-access, a profile that reads only the shared config.toml and secrets.toml, so a key in prod.secrets.toml never reaches it. The shared files apply to every profile and deploy with every environment, so a local run and a deployed run read the same key. Without a key in the configuration, the provider's default environment variable is used (ANTHROPIC_API_KEY, OPENAI_API_KEY, and so on).
A coding agent handles the key like any other secret. It writes a placeholder such as api_key = "<paste-your-api-key-here>" into .dlt/secrets.toml, and you paste the key into the file. The key never goes into a command, an environment variable, or the conversation.
On the platform the runtime can supply a model endpoint of its own. model, api_key, api_url, and api_version are one set. If you set one of them, the run takes all four from your configuration and ignores the endpoint of the runtime. If you set only api_key, the run uses the model of the job, of the agent definition, or the loop default, not the model of the runtime. It sends the request to the public endpoint of the provider, so a key issued for the runtime's endpoint fails with 401 API key is invalid. The run logs which endpoint it used.
Model and credentials as workspace variables
Workspace variables are the other way to set the model and its key, and often the more convenient one for a person: you set them once from a terminal, and every agent job of the workspace deployment gets them. Each variable is the environment form of a key of the agent section:
| Variable | Key | Kind |
|---|---|---|
AGENT__MODEL | agent.model | --plain |
AGENT__API_URL | agent.api_url | --plain |
AGENT__API_VERSION | agent.api_version | --plain |
AGENT__API_KEY | agent.api_key | --secret |
dlthub variable set AGENT__MODEL --value "anthropic:claude-sonnet-5" --plain --workspace
dlthub variable set AGENT__API_KEY --secret --workspace # asks for the key
- Without
--value,variable setreads the value from a prompt or from stdin, so the key stays out of your shell history. - Variables arrive on the runner as environment and override the settings files there.
- A local run gets the plain variables, not the secret ones. For local runs, export
AGENT__API_KEYin your own terminal, or keep the key in.dlt/secrets.tomlas well. --workspacesets a variable for every profile.--profile <name>sets it for the jobs of one profile only, and an agent job runs onno-accessoraccess, not onprod.
Run these commands yourself. A coding agent can set the plain AGENT__MODEL for you, but the key is yours to type.
Read the agent run result
An agent run leaves three things behind, and they answer different questions:
| What | Where | Holds |
|---|---|---|
| Run log | Your terminal on a local run, the run's Logs in the Web UI, dlthub job runs logs | Everything the run printed as it went: the model's reasoning, its messages, each tool call and what it returned, and a closing line listing the tools, skills, and MCP tools used. agent.verbosity sets how much |
| Agent trace | The run's Trace in the Web UI, and trace in the result below | The structured record of the same run: model, limits, resolved inputs, the tools that were wired, turn and token counts, per-turn tool calls |
| Job result | The run's Summary in the Web UI, dlthub job runs info | What the agent returned: status, summary, and the fields its output schema declares |
agent.verbosity controls how much reaches the log:
0: the prompt, the agent's messages, the tool names, tool results cut to 80 characters, and the outcome1(default): adds the agent's thoughts and the tool arguments, each on one line and cut to 200 characters, and tool results cut to 200 characters2: prints thoughts, arguments, and results in full, and adds the rendered system prompt
The log is plain text. Emojis mark its parts: 📝 the prompt, 📜 the system prompt, 🔧 a tool call, 🌐 an MCP tool call, ✅ and ❌ a tool result and the outcome, ❗ an abort, 🏁 a finish without a status, 💭 the agent's thoughts, 💬 the agent speaking, 🎁 the job result. Set agent.emojis to false to print labels and arrows instead.
When the run ends, the launcher prints and delivers the job result:
{
"type": "job.background_agent.dlthub-platform:job-inspector",
"engine_version": 1,
"job_ref": "jobs.__deployment__.job_inspector",
"status": "succeeded",
"summary": "## Diagnosis\n\n- The `load_commits` job failed in the extract step ...",
"result": {
"status": "succeeded",
"summary": "...",
"root_cause": "...",
"failed_run_id": "<run-id>",
"failed_job_ref": "jobs.github_pipeline.load_commits",
"classification": "config",
"confidence": "high",
"evidence": [
{
"source": "`job-runs/<run-id>` line 38",
"excerpt": "...",
"provenance": "run_log"
}
],
"proposed_fix": "...",
"fix_target": "pipelines/github.py",
"fix_change": "cursor_path=\"updated_at\"",
"open_points": [],
"requires_human": true
},
"object": [
{ "type": "job-runs", "id": "job-runs/<run-id>" },
{ "type": "job", "id": "job/jobs.github_pipeline.load_commits" }
],
"trace": {
"loop_type": "pydantic-ai",
"model": "anthropic:claude-sonnet-5",
"turn_count": 3,
"total_tokens": 13215
}
}
statusandsummaryare copied from the agent output to the top level.succeededandfailedmean what the prompt defines.abortedmeans the task couldn't be done at all: the result is delivered, then the run fails with an exception carryingsummary.resultis the agent output as theoutputschema of the agent definition declares it.objectlists the entities the run acted on. On the platform, the job result appears on the page of each entity.traceis the agent trace. It records the model, the limits, the resolved inputs, and the tools that the loop wired. It also records the skills and MCP tools used, the turn and token counts, and the tool calls of each turn.
On the platform, inspect agent runs like any other run with dlthub job runs list and dlthub job runs info. See Monitoring and debugging.
Agent loops
A loop is the framework that runs the agent. dltHub ships two agent loops and adds the matching dependency group to the job, so the runner installs it. A third-party loop can register through the plug_agent_loop plugin hook.
pydantic-ai (default) | claude-agent-sdk | |
|---|---|---|
| Models | Any provider pydantic-ai supports | Anthropic models, through a bundled Claude Code CLI |
| Local tools | dlt's own file, search, and shell tools. Web access comes from the model provider's own search and fetch tools | Claude Code's tools, under the same names |
| Skills | Listed by name and description, loaded on demand | Listed by name and loaded on demand, as in Claude Code |
| Install locally | uv add "pydantic-ai-slim[anthropic,openai,google,mcp,spec]" | uv add claude-agent-sdk |
Both loops read the same declarations. access selects the local tools and tools selects the MCP feature groups. The rendered body becomes the system prompt, instructions becomes the user turn, and output becomes the structured output schema. dlt counts limits.max_tokens after each turn, so the limit means the same on both loops. A turn is one model response, and its input tokens include the tokens read from and written to the prompt cache. The run stops after the turn that passes the limit.
Select the loop on the job with loop="claude-agent-sdk", or for a single local run with -c agent.loop=claude-agent-sdk. The dependency group the job declares follows loop=, so on the platform switch the loop with loop= and deploy. On claude-agent-sdk the workspace's CLAUDE.md loads as in any Claude Code session. The project's .claude/rules and .mcp.json aren't loaded. The agent receives the rules and the MCP server it declares.
Guardrails
- Tools follow the
accessdeclaration. An agent withoutaccessreceives no file tools and no shell. MCP tools declare the access they require, and the model isn't offered a tool that the declared access doesn't cover. - An agent runs no code on the runner unless its agent definition declares
local: execute. Without that verb, the agent has noBashand noRunPython. The agent definitions that the dltHub AI Harness ships don't declare it. Model providers can give a model server-side capabilities on any loop or model, andaccessdoesn't control them. See Access declaration. - Credential files are never readable by a file tool:
*secrets.toml,.env,.env.*, on both loops, whateverlocalgrants. - SQL through the MCP server is limited to a single
SELECTstatement per call. executeruns in the job's own process. A shell runs in the same process tree and virtual environment as the job, with the job's credentials on the runner. It also reaches around the file tools' credential rules. Declare it only in agent definitions that need it. If an agent definition declaresexecuteanddata, give it a rule that forbids writing data.datais an access axis that you declare deliberately: it opens the workspace data to a model-driven process. The agent definitions that the dltHub AI Harness ships declarelocal: readandcontext: readand nodata.job-inspectorlists the restore and data tools, which stay off until a deployment grantsdata: read.- On the platform, an agent job that declares no profile gets the default profile of its data access:
no-accesswithoutdata,accesswithdata: read. The production credentials reach its process only when it declaresdata: write, ordata: readwhileaccesshas no settings files. See Profile of an agent job.
Next steps
- Background agents shows how to build, test, and run agents, one task at a time
- Job inspector agent is the verified agent definition that diagnoses failed job runs
- Triggers and scheduling covers the schedule, interval, and follow-up triggers available to all jobs
- Job configuration covers
execute,require,expose, and TOML sections