Repository navigation
Description
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_waitis 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.
- 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. - Watch the agent's tool calls while the job runs.
- In affected runs, the agent makes repeated
bashcalls likesleep 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
- macOS 27.2, arm64.
- Instructions alone don't seem to fix this. Other agents have similar reports where the agent keeps polling despite explicit instructions: [Bug] Assistant repeatedly issues filler commands while waiting for background tasks despite explicit instruction anthropics/claude-code#97191, Astra/Codex goals: repeated testing and polling despite explicit limits; 454.5M tokens in 24h and major credit depletion openai/codex#56083. Related request in this repo: Feature request: Monitor tool / stream background process output lines as notifications (avoid polling) #5260.
- Possible runtime fixes (suggestions, untested):
- A blocking "wait until this shell/process exits" without the 600 s cap.
- Or an explicit way to end the turn and be woken by the existing completion notification.
- Coalesce redundant waiting-only checks in the runtime and suspend further inference until completion or a meaningful actionable event. Merely denying a call and asking the model to try again can still consume another turn.
- Preserve cancellation, user intervention, failure notifications and legitimate checks for new actionable information.
- Raw transcripts and private workspace data are intentionally omitted. Cached tokens are reported separately, not treated as equal-cost fresh tokens.
Activity