Skip to content

Proposal: Predictable unattended automation runs #574

Open

Description

Tracked in #568. This proposal stands on its own and doesn't depend on the others tracked there.

Summary

Automations usually run when nobody is watching. AHP 1.0 rightly keeps credentials and permission grants out of definitions, but it doesn't say whether automatic runs can start while no client is connected, whose authority a run uses, what happens when a run needs a person at 3 AM, or how long a run may take.

This proposal makes those answers visible and controllable:

  • a capability that says whether unattended runs are possible;
  • display identities for "runs as" and "acted as";
  • two guardrails on the definition that can only make runs more limited: how long to wait for input, and how long a run may take.

Scenarios

  • A nightly job at 3 AM, with no client connected. One host runs it because it holds durable credentials. Another host can start runs only while a client has supplied a live token, so the occurrence misfires. A user needs to know which behavior applies before relying on the schedule, and the client should warn them.
  • Audit. "This run acted as Alice." "This automation runs as the release service account."
  • Stuck at 3 AM. A run reaches a tool confirmation that nobody will answer, and it waits forever.
  • A runaway run. A run keeps working for hours.

AHP today

  • Definitions carry no credentials, confirmation decisions, or durable permission grants. This proposal keeps it that way.
  • In AHP, clients supply credentials (authenticate for protected resources). Nothing says whether automatic runs depend on a connected, authenticated client.
  • Nothing identifies whose authority a run uses.
  • A run stays running while a linked session awaits input. SessionState.inputNeeded is authoritative for that, and there's no bound on how long it lasts.
  • Timeouts exist only as host configuration that clients can't see.

Proposal

  1. Unattended capability. automations.execution.unattended: boolean.

    • true: automatic runs can start while no client is connected.
    • false: automatic runs start only while an authenticated client is connected. Otherwise, schedule occurrences follow their misfire policy and other runs wait in pending.
    • Absent: unspecified, as today.

    Clients SHOULD warn users when they add automatic triggers on a host that advertises unattended: false.

  2. Identity, for display only. AutomationEntry.runAs is the principal automatic runs act as, when the host knows it before a run. AutomationRunState.actor is the principal a run actually acted as. Both are { id, displayName? }. They're informational and confer no authority. Hosts omit them where they aren't meaningful, such as on a single-user host.

  3. Input wait limit. AutomationDefinition.inputTimeoutMinutes bounds how long a run may wait for a person.

    • What counts. Requests for a person raised by the run's own work: chat input requests, tool confirmations, and tool authentication (SessionInputRequestKind chatInput, toolConfirmation, and toolAuthentication). Client tool execution (toolClientExecution) is delegated work, not a question for a person, so it doesn't count; the run time limit covers it. Requests from unrelated work in a shared session don't count.
    • The clock. The wait starts when the run's work first has an outstanding request that counts, and it resets when none remain. The deadline is durable, so a host restart doesn't reset it.
    • On expiry. The host cancels the run's outstanding work (its active turns and any of its queued messages) and fails the run with an ErrorInfo (for example, errorType: 'inputTimeout'). 0 fails the run as soon as such a request appears. When the field is absent, the run waits, as it does today.
    • The host never answers, approves, or declines anything on the user's behalf.
  4. Run time limit. AutomationDefinition.timeoutMinutes. The host fails a run that is still running this long after it started, cancelling its outstanding work, with an ErrorInfo (for example, errorType: 'timeout'). Hosts may enforce a lower maximum. They publish the effective value in the stored definition and may advertise the maximum.

  5. Guardrails only narrow. Both limits only end runs sooner. They never grant permissions, approve confirmations, or widen what a run can do.

  6. Capabilities. automations.execution carries unattended. automations.timeouts, a separate capability, says the host enforces both limits, so clients author them only when the host will honor them.

Sketch

Names and shapes are illustrative. The implementation PR settles them.

interface AutomationCapabilities {
  // ...existing fields
  execution?: {
    /** Whether automatic runs can start while no client is connected. */
    unattended: boolean;
  };
  /** Present when the host enforces inputTimeoutMinutes and timeoutMinutes. */
  timeouts?: { maxTimeoutMinutes?: number };
}

interface AutomationDefinition {
  // ...existing fields
  /** Fail the run once its own work has waited this long for a person. 0 = immediately. */
  inputTimeoutMinutes?: number;
  /** Fail the run once it has been running this long. */
  timeoutMinutes?: number;
}

/** Display-only identity. Confers no authority. */
interface AutomationPrincipal {
  id: string;
  displayName?: string;
}

interface AutomationEntry {
  // ...existing fields
  runAs?: AutomationPrincipal;
}

interface AutomationRunState {
  // ...existing fields
  actor?: AutomationPrincipal;
}

Why this shape

  • Unattended execution follows from AHP's authentication model. Clients supply tokens, so "can this host act while no client is connected?" is a question about AHP itself, not a quirk of one host. Clients can't warn users accurately without the answer.
  • Session state stays authoritative. The input limit doesn't copy input-needed state onto the run. It only adds a deadline to state the session already reports.
  • Outcomes use existing states. A run that times out is failed with an ErrorInfo. No new statuses are needed.
  • Narrowing only. Definitions still carry no grants or confirmation decisions. These fields can only stop a run sooner.

Compatibility

  • Additive. The capability and definition fields are optional, and identities are optional state.
  • Clients author the guardrails only when the host advertises timeouts, because an older host would silently ignore them.

Out of scope

These stay in the host's session configuration (session.config, described by the host's config schema, which clients already render) or behind the host boundary:

  • Tool allow-lists and write scopes, such as branch patterns or repository allowlists. These use host-specific vocabularies.
  • Choosing a sandbox or execution environment.
  • Limits on the agent's loop, such as a maximum number of model calls. These are agent implementation details.
  • Auto-approval modes. These are permission grants, which definitions must not carry.

Open questions

  1. Should unattended be per host (proposed) or per automation? A host might hold durable credentials for some automations but not others.
  2. When the input limit expires, should the run fail (proposed) or be cancelled?
  3. Should timeoutMinutes count from when the run started (proposed) or from when it was admitted, so time spent waiting in pending also counts?
  4. Several proposals need a display identity. Should it be a shared protocol type rather than one specific to automations?

Related proposals (none required)

Metadata

Metadata

Labels

feature-request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions