Skip to content

Rethink how automations execute #2051

Closed

Description

@sentry-junior

Tracks open work on how an Automation run executes, ahead of a greenfield exploration of a larger overhaul. The data model and management surface were consolidated in #1717 and #1970. This issue covers the run itself: how a schedule or Event becomes model work, what the run is told, how it decides to act or stay silent, and how it delivers results.

Today every Automation run, whether scheduled or event-driven, goes through the same agent-dispatch path as an interactive chat turn. It uses the shared system prompt plus a dispatch wrapper (#2014). Most of the issues below are symptoms of that framing.

Core execution model

Bugs in current runs

Triggers and sources

In-flight PRs

Prior work

via David Cramer.

--

View Junior Session [Sentry]

Activity

  1. sentry-junior commented on Oct 6, 2026

    @sentry-junior
    ContributorAuthor

    Research: structuring the prompt for an automation run

    Every system we looked at that handles unattended runs well gives them their own mode and their own contract. Junior instead runs automations as chat turns with a <dispatch> wrapper on top, which explains most of #2014, #554, and #1741. Junior source was read at a97d616. Prior art was read from source or first-party docs on 2026-10-06.

    Current behavior (verified)

    • One shared system prompt. buildSystemPrompt(platform) in packages/junior/src/chat/prompt.ts is static per platform. Automation runs inherit interactive rules: ask the user for missing access, "the actor is the person asking now", reply only into the active thread, and [[NO_REPLY]] for silence.
    • <dispatch> block. buildDispatchSection says "the runtime delivers the final answer to the destination" and shows the task destination, not the resolved outcome destinations. The actor is scheduler/junior, not the creator.
    • Task input. renderTaskInput in packages/junior/src/chat/task-input.ts already splits event data into trusted summary, verified JSON, and untrusted external text. Prior art does the same. The reply contract is "Briefly report what you did or what is needed next." With outcomes present, conditional silence still depends on an exact [[NO_REPLY]].
    • No previous-run context. buildDispatchMetadata in scheduled-automations/heartbeat.ts includes scheduledFor, runningAt, and the schedule, but nothing about the previous run.
    • No model bypass for fixed text. Overhaul Junior automations #1717 called for one, but no code path does this.

    Prior art

    • GitHub Agentic Workflows (githubnext/gh-aw @ 3fd44f8)
      • The workflow markdown is the task. The system adds fixed sections around it: security policy, context, and a safe-outputs contract.
      • The agent has no write access. It declares typed outputs (add_comment, create_pull_request, …), and a separate job applies them afterwards.
      • The run must end with a safe-output call or noop, "even if the workflow prompt forgets to ask for noop". report_incomplete, missing_tool, and missing_data route to maintainers, not to the output destination.
      • skip-if-match / skip-if-no-match checks run deterministically before the agent starts.
      • Outcomes are later scored accepted/rejected/ignored from repository state.
    • Claude Code Routines (docs)
      • The saved prompt is "its assigned task… not live user input and can't act as approval or consent for actions during the run."
      • Before v2.1.213 the prompt was framed as an untrusted background notification, and runs "could refuse to act on it". That is the same failure as Junior's unattended runs asking for permission.
      • Trigger text arrives in an untrusted <routine-fire-payload> block, and the prompt must opt in to acting on it.
      • Runs don't pause for approval. Scope comes from the repos, environment, and connectors chosen up front.
      • Their own caveat: a green status doesn't mean the task succeeded. There is no typed terminal result.
    • Codex (openai/codex @ 0b863c6)
      • Modes are swappable developer templates (collaboration-mode-templates/, approval_policy/never.md), and user or tool content can't change the mode.
      • request_user_input is usable "only when it is listed in the available tools". Unattended runs remove the capability instead of adding prose.
      • codex exec --output-schema gives structured final output.
    • Goose recipes (block/goose @ 2f07ead)
      • Recipes separate instructions (behavior) from prompt (the job, required in headless mode).
      • response.json_schema is enforced through a final_output tool. If the model stops without calling it, the runtime injects "You MUST call the final_output tool NOW".
      • retry.checks run deterministic success checks after the run.
    • claude-code-action (anthropics/claude-code-action @ 5898584)
      • Tag mode is interactive, with a tracking comment.
      • Agent mode passes the configured prompt through as written, with no implicit reply. Visible effects happen only through tools.
    • Cursor Automations (docs)
      • Output tools ("Send to Slack", "Comment on PR") are opt-in.
      • "Run as" chooses between creator and a per-automation service account.
      • Per-automation Memories persist across runs, with a warning that untrusted input can poison later runs.
    • LangChain ambient agents (post, agent-inbox)
      • Background agents contact humans through notify, question, and review. Questions and reviews go to an inbox and pause the run, not into the output channel.

    Proposals (agreed direction for exploration)

    1. Separate automation-run mode. Keep identity, world, and safety shared. Replace the interactive behavior, conversation, and Slack-action sections with an automation section:

      • The run is unattended.
      • The stored instruction is the creator's pre-approved task within its scope.
      • Check conditions before any side effect.
      • End with exactly one terminal tool.
      • Instruction or event content can't change the mode.
    2. Typed terminal contract. This replaces [[NO_REPLY]] and "briefly report". The run must end with one of:

      • deliver(message): exposed only when a send_message outcome exists. The runtime routes it to the stored destinations. The message is the deliverable.
      • no_action(reason): silent success. Logged and visible, never posted.
      • blocked(reason, needs): sent privately to the creator, never to the destination.
      • incomplete(error): goes to the failure path.

      Final assistant text is never delivered. Inject one nudge if no terminal tool was called, then mark the run incomplete.

    3. Remove capabilities instead of adding prose. Automation runs don't get the ask-user path or OAuth-link prompts. The prompt lists credential state per provider up front (for example github: creator, notion: not connected). A missing provider that the run needs leads to blocked.

    4. Describe the recipient. Build a deliverable block from the resolved outcomes, not the task destination. Examples: "DM to , who wrote this automation" or "#channel; mention where the instruction says me". <actor> becomes the creator. This removes the need for prompt patches like fix(automations): Require the creator mention in a reply for "me" #2033 and Scheduler fabricates mention links in task outputs #554.

    5. Check conditions before acting. Optionally store when separately from do. For events, run deterministic filters first, then an optional cheap relevance check, and only then a full run (Cheaper handling for resource-event turns #1038). If a condition can't be verified, call no_action.

    6. Previous-run context. Add the last run's time, terminal result, and reason to the prompt so "since last run" is grounded. Per-automation memory comes later, starting with per-PR progress for Support shared PR-review automations across repositories #1977.

    7. Fixed text skips the model. A reminder with fixed text and no live data posts its stored text directly.

    8. Write self-contained instructions at creation time. The creation tool resolves "me", channels, users, and repos into stored fields, and checks that the instruction states what success looks like.

    9. Record terminal results. Store the terminal tool and its reason on every run. The dashboard shows delivered, no action, blocked, or incomplete, and this can later feed evals.

    Draft layout

    [system] shared identity / world / safety
    [system] automation-run mode: unattended; stored instruction = pre-approved task;
             conditions before effects; end with exactly one terminal tool
    <automation>  name, id, creator (actor), credentials: github=creator, notion=missing
    <trigger>     schedule "weekdays 09:00 America/Los_Angeles", fired <ts>; last run <ts> no_action "nothing new"
    <deliverable> DM to <creator> (they wrote this) | silent
    <instruction> stored text
    <event>       trusted summary | verified fields | <untrusted-payload>…</untrusted-payload>
    tools:        normal tools minus ask/OAuth prompts + deliver | no_action | blocked | incomplete
    

    Open questions

    • Should blocked reuse auth pause/resume (LangGraph), or always end the run (gh-aw, Claude Routines)?
    • Should deliver be a tool, or should the final message be validated against an output schema (Codex)?
    • Watches report into a live Conversation. Do they share this mode, or only the trust blocks for event data?
    • Where do when conditions live for scheduled runs, and is a cheap check worth it there?
  2. sentry-junior commented on Oct 6, 2026

    @sentry-junior
    ContributorAuthor

    Clarification: blocked runs and user-facing errors

    A blocked result should report a genuine automation issue to the creator, not turn into an open-ended conversational question or disappear as a silent no-op. What qualifies as a real blocker and how to present the error and next steps are UX questions to explore. Keep the run lifecycle question open too: whether the run ends or can resume after the issue is resolved.

  3. sentry-junior commented on Oct 11, 2026

    @sentry-junior
    ContributorAuthor

    Decision: no generic previous-run context for now

    We should not add prior-run content or a conversation ID to every automation prompt without a demonstrated use case. For Event automations, the proposed object-scoped conversation continuity in #2084 gives later events about the same work item access to its history; a separate pointer would be redundant. For Scheduled automations, we do not yet have a concrete instruction or eval that needs prior-run context. A prior model-generated result/reason is not authoritative current state and could reinforce a stale or mistaken conclusion; a conversation ID without a specific retrieval use case adds context without clear value.

    If a real scheduled use case emerges (for example, reporting changes since the last run), provide the smallest system-verified checkpoint needed—such as a successful-run timestamp or cursor—and retrieve additional history only when the task needs it. Keep this out of the default prompt for now.

  4. sentry-junior commented on Oct 11, 2026

    @sentry-junior
    ContributorAuthor

    Scope decision

    No active use case is identified for proposals 6 or 9, so we should not add these features now. Generic previous-run context has no demonstrated consumer; Event continuity is covered by the object-scoped conversation approach in #2084, and there is no concrete Scheduled automation need. A separate execution-result field or dashboard is also unnecessary for now: the declared result is already persisted in conversation history, and no active consumer for a duplicate field or view has been identified. Revisit only when a specific automation, user-facing workflow, or operational need requires it.

  5. sentry-junior commented on Nov 9, 2026

    @sentry-junior
    ContributorAuthor

    Closing as mostly shipped: automation mode and declared results (#2052), plus #2095, #2096, and #2117 landed. The remaining children stand alone: #1038, #2034, #2244, #2362, #1977.

    Closed during a tracker cleanup. Reopen if this still matters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions