Skip to content
Français

Set deadlines and cancel work

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

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 { reportValue } from "./reporter.ts";
import { dispatch } from "@elie-laloum/outpost";
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,
});
reportValue(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.

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";
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.

Repeat the brief until the agent declares it done

Section titled “Repeat the brief until the agent declares it done”

passes sends the brief again when a pass ends without a completion marker. Ask for the marker in the brief: Outpost does not add it.

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

const result = await dispatch({
  repository,
  sandboxProvider,
  agent: coder,
  branch: { mode: "named", name: "outpost/flaky-tests" },
  brief: {
    text: "Fix the flaky tests and commit. When every test passes, end your answer with READY_FOR_REVIEW.",
  },
  passes: 3,
  until: "READY_FOR_REVIEW",
});
reportValue(result.completed, result.completion);
// Example output: true READY_FOR_REVIEW

Each pass starts a new conversation on the same branch, so it sees the previous commits. Outpost stops at the first pass whose answer contains a marker. until also accepts a list; until: [] disables matching and runs every pass.

API reference: DispatchResult.

If the agent writes its marker but keeps running, Outpost stops it settleMs after its last output. The result is kept and warn receives a message.

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";
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.