Skip to content

Agent spends model turns on sleep N; check polling while a background job runs #5459

Open

Description

@gk2go

Describe the bug

While a long background job was running, the agent kept making bash calls of the form sleep N; <tail the log / check the process>. Each call was a separate model turn that re-read the whole conversation context. None of these turns produced anything to act on until the job finished. The runtime already notifies the agent when a backgrounded shell completes, so these turns could have been avoided.

Measured from one interactive session's events.jsonl. I joined session.usage_record to assistant.message by apiCallId:

Metric Value
Turns whose tool call was sleep 45–sleep 540 plus a status check 13
Fresh tokens (inputTokens − cacheReadTokens + outputTokens) 22,651
Cache-read tokens (103k–131k per turn) 1,504,754
AI units (copilotUsage.totalNanoAiu / 1e9) 18.44

Model selection: Auto.

This doesn't happen every time. I ran 3 headless ACP runs (copilot --acp --allow-all --no-ask-user --no-custom-instructions, default model). Each was asked to make a check pass, which required a background job of about 250–280 s. In every run, the agent started the job and waited for it in one blocking bash call (initial_wait 300–600), so no turns were spent waiting. However:

  • The tool's initial_wait is capped at 600 s. A longer command outlasts that synchronous window, but this does not mean repeated model turns are necessary: the agent could yield and resume on completion.
  • These were three short ACP runs, not a controlled before/after demonstration of a fix in the interactive app.
  • All six underlying test suites in the two-provider comparison exited nonzero. This measures waiting overhead, not successful task completion.

Affected version

GitHub Copilot desktop app 1.4.1 (confirmed through the serving app's build-info tool), bundled runtime copilot-sdk-runtime-1.0.106-8.unstable.r43360710077 (copilot --version: GitHub Copilot CLI 1.0.112).

Steps to reproduce the behavior

This is not deterministic.

  1. In an interactive session, have the agent start a job in the background (async bash) that takes 5–40 minutes, for example a test suite. Ask it to report the results when the job is done.
  2. Watch the agent's tool calls while the job runs.
  3. In affected runs, the agent makes repeated bash calls like sleep N; tail <log>; <process check>, each costing one model turn.

Expected behavior

Once the only remaining work is waiting, the agent should do one of two things:

  • end its turn and resume when the completion notification arrives, or
  • make a single blocking wait.

It shouldn't repeat sleep-and-check turns that return nothing to act on.

Additional context

Activity

  1. added
    area:agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agents
    area:toolsBuilt-in tools: file editing, shell, search, LSP, git, and tool call behavior
    and removed on Nov 15, 2026
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

    area:agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agentsarea:toolsBuilt-in tools: file editing, shell, search, LSP, git, and tool call behavior

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions