Skip to content
Français

Set deadlines and cancel work

Bound agent execution time, control repeated passes and cancel from your code.

Use the setup configuration for these dispatch examples. Choose deadlines before starting unattended work, and decide how you will inspect a retained branch after cancellation. The workflow budget bounds cumulative work separately.

Set deadlines alongside the brief when a task needs tighter limits than the defaults. You can bound the whole agent turn and the time it may remain silent.

import { dispatch } from "@elie-laloum/outpost/core";
import { coder, repository, sandboxProvider } from "./outpost.config.ts";

const result = await dispatch({
  repository,
  sandboxProvider,
  agent: coder,
  branch: { mode: "named", name: "outpost/parser-fix" },
  brief: { text: "Fix the parser and commit the change." },
  deadlineMs: 20 * 60_000,
  idleMs: 5 * 60_000,
});
console.log(result.text);
// Example output: Fixed the failing tests and committed the change.

If the agent runs longer than 20 minutes, or stays silent for 5, the promise rejects with an OutpostError of code timeout. The sandbox is released; the branch keeps what the agent committed.

deadlineMs bounds a dispatch’s total duration; idleMs watches its silence. A task attempt uses timeoutMs, while the workflow sets its own deadline with start({ timeoutMs }). Start with a total deadline, then add silence detection only when a long quiet operation should be interrupted.

API reference: DispatchOptions.

Your observe callback receives a stopped event whose reason says which one ended the process: deadline, idle-timeout, completion or aborted.

Pass an AbortSignal. Here, Ctrl+C stops the agent instead of leaving it running in the sandbox.

import { dispatch, recoveryDetails } from "@elie-laloum/outpost/core";
import { coder, repository, sandboxProvider } from "./outpost.config.ts";

const controller = new AbortController();
process.once("SIGINT", () => controller.abort("cancelled by user"));

try {
  await dispatch({
    repository,
    sandboxProvider,
    agent: coder,
    branch: { mode: "named", name: "outpost/refactor" },
    brief: { text: "Refactor the auth module and commit the change." },
    signal: controller.signal,
  });
} catch (error) {
  console.error(error, recoveryDetails(error));
}

The promise rejects with the value passed to abort(), here "cancelled by user". AbortSignal.timeout(ms) works the same way for a deadline that spans every pass.

After a stopdispatch()sandbox.dispatch() in a session
Agent processIts process group and descendants terminatedSame
SandboxReleasedStill running, ready for the next dispatch
Worktree, branchKept; recoveryDetails(error) gives bothKept

To change the agent’s direction without stopping it, steer it instead.

For this step, follow Repeat the brief until the agent declares it done.

limits sets deadlines on the Git and file steps around the agent. Pass it to dispatch(), createWorkspace() or createSandbox().

import { dispatch } from "@elie-laloum/outpost/core";
import { coder, repository, sandboxProvider } from "./outpost.config.ts";

await dispatch({
  repository,
  sandboxProvider,
  agent: coder,
  branch: { mode: "integrate" },
  brief: { text: "Update the lockfile and commit the change." },
  limits: { gitMs: 120_000, mergeMs: 120_000 },
});

API reference: StageLimits.

  • Every duration must be a positive number: 0 does not disable a limit.
  • passes above 1 cannot be combined with response or continuation.
  • Stopping an agent does not roll anything back. Commits and files it already wrote stay on the branch.

API: dispatch · DispatchOptions · DispatchResult · StageLimits · recoveryDetails · AgentObservation.