claude-code - 💡(How to fix) Fix Agent enters infinite "Puttering" loop after task completion — consuming tokens with no output [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52362Fetched 2026-04-24 06:09:10
View on GitHub
Comments
2
Participants
2
Timeline
11
Reactions
1
Timeline (top)
cross-referenced ×4labeled ×4commented ×2subscribed ×1

After completing a full agentic task (web searches + structured response), Claude Code entered an infinite internal loop showing only:

✻ Puttering… (27s · ↓ 783 tokens · still thinking)

This repeated 50+ times without any new output, user interaction, or task progress — burning tokens continuously until manually interrupted.


Error Message

Error Messages/Logs

Root Cause

After completing a full agentic task (web searches + structured response), Claude Code entered an infinite internal loop showing only:

✻ Puttering… (27s · ↓ 783 tokens · still thinking)

This repeated 50+ times without any new output, user interaction, or task progress — burning tokens continuously until manually interrupted.


Code Example

Puttering… (27s · ↓ 783 tokens · still thinking)

---

Puttering… (27s · ↓ 783 tokens · still thinking)

Repeated dozens of times until manually interrupted with Ctrl+C.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Bug Report: Agent enters infinite "Puttering" loop after completing task — consuming tokens with no output


Summary

After completing a full agentic task (web searches + structured response), Claude Code entered an infinite internal loop showing only:

✻ Puttering… (27s · ↓ 783 tokens · still thinking)

This repeated 50+ times without any new output, user interaction, or task progress — burning tokens continuously until manually interrupted.


Steps to Reproduce

  1. Send a research-heavy prompt requesting multiple parallel web searches and a structured comparative response
  2. Agent completes all searches and generates the full final answer
  3. Agent does not terminate — instead enters a "Puttering" state loop
  4. Loop repeats indefinitely (observed 50+ iterations) with no output and no stop condition

Prompt sent (translated from Portuguese)

"I need ideas to invest up to R$50,000 in a self-scaling business in Brazil. The money will be paid in installments, so the business must cover payments and generate profit. Give me at least 5 real, logical ideas — no hallucination or dreaming. Use specialist skills and web search."


Observed Behavior

  • Agent ran 6 web searches correctly
  • Agent generated a complete, well-structured final answer (5 business ideas with comparative table)
  • Instead of terminating, agent re-entered internal loop
  • Terminal showed ✻ Puttering… with token counter incrementing on every cycle
  • No new output was produced
  • Loop only stopped via manual interruption (Ctrl+C)

Expected Behavior

Agent should detect task completion after delivering the final response and terminate cleanly.


Environment

  • OS: macOS (Apple Silicon M4 Pro)
  • Claude Code version: 2.1.118 (Claude Code)
  • Shell: zsh
  • Task type: multi-step agentic with web search tools

Impact

This is not a minor UX issue. The infinite loop consumed a significant number of tokens after the task was already complete, resulting in real financial cost to the user with zero value delivered. This has occurred more than once.

Requesting:

  1. A fix for the missing termination condition after task completion
  2. Clarification on whether token consumption during "Puttering" loops qualifies for usage credit

Additional Notes

The agent's final output before the loop was complete and correct — this is purely a loop/termination control bug, not a generation quality issue.

What Should Happen?

After delivering the final response, the agent should detect task completion and terminate cleanly without re-entering any internal loop.

Error Messages/Logs

✻ Puttering… (27s · ↓ 783 tokens · still thinking)

Repeated dozens of times until manually interrupted with Ctrl+C.

Steps to Reproduce

  1. Send a research prompt requesting multiple parallel web searches and a structured response
  2. Agent runs all searches and delivers a complete final answer
  3. Agent does not terminate — enters "Puttering" loop instead
  4. Terminal shows: ✻ Puttering… (27s · ↓ 783 tokens · still thinking)
  5. Loop repeats dozens of times with no output until manually interrupted with Ctrl+C

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.118 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

The agent's failure to terminate after completing a task and entering an infinite "Puttering" loop can be addressed by investigating and fixing the termination condition logic in the Claude Code.

Guidance

  • Review the task completion detection logic to ensure it correctly identifies when a task is finished and triggers termination.
  • Verify that the agent's state is properly updated after delivering the final response to prevent re-entry into the "Puttering" loop.
  • Check for any recent changes in the Claude Code version 2.1.118 that might have introduced this regression, comparing it with the last known working version.
  • Consider adding logging or debugging statements to track the agent's state and decision-making process during task completion to identify where the loop condition is being met incorrectly.

Example

No specific code example can be provided without access to the Claude Code's source, but a hypothetical fix might involve ensuring a task completion flag is set after the final response is generated:

# Pseudo-code example
if task_completed:
    agent_state = "terminated"
    # Prevent re-entry into the loop
    return

Notes

The exact fix depends on the internal workings of the Claude Code and the Anthropics API, which are not fully detailed in the issue report. The guidance provided is based on the information given and aims to point towards a logical troubleshooting and fix direction.

Recommendation

Apply a workaround by manually monitoring and interrupting the agent when it enters the "Puttering" loop after task completion, while awaiting a fix for the termination condition logic. This is due to the financial impact of token consumption during these loops and the regression nature of the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Agent enters infinite "Puttering" loop after task completion — consuming tokens with no output [2 comments, 2 participants]