Skip to content

[Bug]: [Presets] A repeatedly dying agent retries forever instead of failing #4163

Open

Description

@peterschmidt85

Steps to reproduce

  1. Make the agent process die at startup without submitting a report, in a way that still prints one assistant line. For example, with subscription auth supplied only by user-scope settings while the native OAuth session is expired: dstack spawns claude with --setting-sources project,local (agent.py:356-357), which excludes the user scope, so the agent starts and dies immediately.
  2. Start any preset creation: dstack apply -f preset.dstack.yml -y.

Actual behaviour

Agent process exited without a report; resuming in 30s.

repeats every 30 seconds, indefinitely, before any instance is provisioned. Never 60s or 120s: agent.py:551-552 sets made_progress on any assistant line without inspecting its content, and agent.py:238-239 resets the retry budget (agent.py:52) before the pop at agent.py:246, so the budget never drains and the while True at agent.py:216 has no attempt cap. The agent's own error is captured at agent.py:555-556 but the loop message omits it, so the cause is only visible in .agent-stdout.jsonl. A report-less death that prints no assistant line does bound correctly and exits after 30/60/120s.

Expected behaviour

The creation fails immediately, printing the agent's error:

Failed to authenticate: OAuth session expired and could not be refreshed

Retries stay only for a transient death after real progress, bounded, printing the error each attempt.

Activity

  1. changed the title [-][Presets] Agent startup and auth failures retry forever instead of failing[/-] [+][Bug]: [Presets] Agent startup and auth failures retry forever instead of failing[/+] on Aug 18, 2026
  2. changed the title [-][Bug]: [Presets] Agent startup and auth failures retry forever instead of failing[/-] [+][Bug]: [Presets] A repeatedly dying agent retries forever instead of failing[/+] on Aug 18, 2026
  3. breken-ai commented on Sep 9, 2026

    @breken-ai

    Reproduced on current HEAD. The retry budget still resets on any assistant output, so the crash loop you described is still unbounded: an agent that prints one assistant line then dies (your expired-OAuth case) makes identical progress every attempt. The loop's made_progress boolean can't distinguish "got further" from "got to the same place again". This changes it to an assistant-line count and only resets the budget when an attempt exceeds the best previous attempt, so a dying agent drains the 30/60/120s retries and returns the error while a genuinely progressing one still earns resets. Includes an end-to-end regression test with a fake claude process that dies after one assistant line: unbounded on main, exactly 4 attempts with the fix. PR: #4277

    Built by breken, your AI support engineer - breken.ai finds the bug, proves the fix with unmatched RCA, answers customers in your voice, and keeps your code and support docs clean - this one's on us.

  4. github-actions commented on Oct 10, 2026

    @github-actions

    This issue is stale because it has been open for 30 days with no activity.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions