Deliver content to jobs
Prepare a verified version of a bundle for each job and report job starts.
A job is one production run of your agent. Prepare the released version of a bundle for each job, record the version with the result and clean up. A job keeps the version it prepared even if a release lands while it runs. See Delivery.
For Codex, the Claude Agent SDK, Pi or Cursor, see Use a coding agent.
Before you start
- Install the SDK.
- Create a connection for the bundle and channel, and issue its connection credential. See Connect your application and Credentials and rights.
- Run the delivery check in the First delivery step of the connection's Setup tab. Then choose Bundle & channel and Full setup guide to open App setup.
The snippets take the API URL and the workspace, bundle and connection IDs from App setup, and read the connection credential from ACCLIMATE_TOKEN.
Prepare a job
Call prepare once for each job and give your agent the prepared system prompt and skill files. Save the version ID and digest with the result.
import { AcclimateClient } from '@acclimate/sdk';
const client = new AcclimateClient({
baseUrl: 'https://api.acclimate.example.com',
token: process.env.ACCLIMATE_TOKEN!,
connectionId: CONNECTION_ID,
});
const prepared = await client.prepare({ workspaceId: WORKSPACE_ID, bundleId: BUNDLE_ID, channel: 'stable' });
try {
const result = await runAgent(jobInput, {
systemPrompt: prepared.systemPrompt,
skillFiles: prepared.skillFiles,
});
const { id: versionId, digest } = prepared.version.version;
await saveJobResult(result, { versionId, digest });
} finally {
await prepared.cleanup();
}The IDs, job input, agent call and result storage are your application's. Send systemPrompt as the system message. It is exactly what a learning rollout sends, so production runs the prompt the loop scores. The prepared job has these properties, with snake_case names in Python:
| Property | Contents |
|---|---|
systemPrompt | The instruction, skill and memory files as one system message, each under a # <path> heading |
instructions | The instruction files only, joined into one string |
skillFiles | The staged skill files, each with path, kind and absolutePath |
files | Every staged file, including memory files |
version | The verified version, with its ID and digest in version.version (version["version"] in Python) |
directory | The private job directory |
Clean up only after the job has stopped and its result is saved. For background work, keep the prepared object and call cleanup() when the job stops.
To run an exact version instead of the channel's current one, pass versionId (version_id in Python) in place of channel.
createAcclimate().job() (Acclimate.from_env().job() in Python) finds a bundle by name and reports learning outcomes with expect(). It does not work with a connection. It needs a machine token with read (and write for expect()), and sends no start receipts. See Jobs in the TypeScript SDK and Python SDK references, and Support agent for an application built on it.
Serve jobs from a long-running service
| Concern | What the SDK does |
|---|---|
| Latency | One request per job resolves the channel. After the first download, files come from a verified disk cache, 20 MiB by default. Each job gets a new private directory. |
| Service down | A channel prepare fails without a retry, after at most the client timeout, 30 seconds by default. Set timeoutMs (timeout in seconds in Python) to what a request can afford. |
| Pinning | Only a prepare with an exact version and the offline option falls back to the cache, after a transport failure or an HTTP 502, 503 or 504. |
Create one client for the process. Prepare each job from the channel and remember its version, then prepare that version from the cache when the service is unreachable. A process that starts during an outage has no version to fall back to. The Python SDK is synchronous, so an async def route runs the whole prepare, run and cleanup in a worker thread, as in this FastAPI sample.
import { ApiError, TransportError } from '@acclimate/sdk';
let lastVersionId: string | undefined;
async function prepareJob() {
try {
const prepared = await client.prepare({ workspaceId: WORKSPACE_ID, bundleId: BUNDLE_ID, channel: 'stable' });
lastVersionId = prepared.version.version.id;
return prepared;
} catch (error) {
const outage = error instanceof TransportError || (error instanceof ApiError && [502, 503, 504].includes(error.status));
if (!outage || !lastVersionId) throw error;
return client.prepare({
workspaceId: WORKSPACE_ID,
bundleId: BUNDLE_ID,
versionId: lastVersionId,
offline: { pinnedVersionId: lastVersionId },
});
}
}Report job starts
A start receipt records which version a job used. Reporting is optional, and a failed report never blocks delivery.
- On the connection's Credentials tab, choose Create receipt credential and give the secret to the application in
ACCLIMATE_RECEIPT_TOKEN. - Build one reporter for the process, with its own client, and pass it to every
prepareasreporter. - At the job's real start event, call
reportStarted()and keep the returned receipt with the job ID. It returnsnull(Nonein Python) when reporting is unavailable, including after the reporter is closed. - Close the reporter at shutdown.
The reporter keeps a failed receipt for up to 24 hours. TypeScript retries it with the next receipt, Python only when you call reporter.flush(). Python's reporter.wait() blocks, so call it only at shutdown.
import { AcclimateClient, createReceiptReporter } from '@acclimate/sdk';
// Once for the process
const reporter = createReceiptReporter({
workspaceId: WORKSPACE_ID,
connectionId: CONNECTION_ID,
client: new AcclimateClient({
baseUrl: 'https://api.acclimate.example.com',
token: process.env.ACCLIMATE_RECEIPT_TOKEN!,
scope: 'support-app:receipts',
timeoutMs: 1000, // a short deadline and no retries, so reporting cannot delay the job
retries: 0,
}),
});
// For each job, then run it and clean up as in "Prepare a job"
const prepared = await client.prepare({ workspaceId: WORKSPACE_ID, bundleId: BUNDLE_ID, channel: 'stable', reporter });
const receipt = prepared.reportStarted(); // at the job's real start event
// At shutdown
await reporter.flush();
reporter.close();Next steps
- Move a channel to a new version with Release and roll back.
- Let the service improve the bundle with Run a learning loop.
- Look up every call in the TypeScript SDK and Python SDK references.
Improve a support agent
Answer support requests with a released bundle, improve the bundle with sample tasks and turn a person's correction into a learning task.
Use a coding agent
Run Codex, the Claude Agent SDK, Pi or Cursor on a verified bundle version, in a private directory in the layout each agent reads.