67 pages for loops.
Titles and paths first, then pages whose text carries it. Each row opens that page as this site last read it.
optimizing-for-cost-and-intelligence
Claude Developer Platform · in the page
about-claude/models/optimizing-for-cost-and-intelligence
…for-cost-and-intelligence#re-run-failures-at-higher-effort) | | Agent loops with a few very costly runs | Set a Claude Managed Agents session budget and a workspace spend limit | [Set budgets](https:/…
PDF Processing
Claude Developer Platform · in the page
agents-and-tools/agent-skills/best-practices
…-environment) section later in this guide. ## Workflows and feedback loops ### Use workflows for complex tasks Break complex operations into clear, sequential steps. For particularly complex workfl…
claude-api-skill
Claude Developer Platform · in the page
agents-and-tools/agent-skills/claude-api-skill
…atch processing, prompt caching, structured outputs, and custom agent loops * **Claude Managed Agents (beta):** An Anthropic-hosted surface for server-managed stateful agents with Anthropic-hosted too…
advisor-tool
Claude Developer Platform · in the page
agents-and-tools/tool-use/advisor-tool
…three advisor calls and improves from there. Enable it for long agent loops, and keep it off for short tasks. **Keep it consistent:** Set `caching` once and leave it for the whole conversation. Toggl…
computer-use-tool
Claude Developer Platform · in the page
agents-and-tools/tool-use/computer-use-tool
…teration limit is reached. This safeguard prevents potential infinite loops that could result in unexpected API costs. ### Optimize model performance with prompting 1. Specify well-defined tasks and…
parallel-tool-use
Claude Developer Platform · in the page
agents-and-tools/tool-use/parallel-tool-use
…cordion> </AccordionGroup> <Note> **Claude Fable 5.1 in long agent loops** Claude Fable 5.1 may issue fewer parallel tool calls than earlier models, most noticeably in long agent loops where the…
Process results programmatically
Claude Developer Platform · in the page
agents-and-tools/tool-use/programmatic-tool-calling
…n": "end_turn" } ``` ## Advanced patterns ### Batch processing with loops Claude can write code that processes multiple items efficiently: ```python regions = ["West", "East", "Central", "North",…
text-editor-tool
Claude Developer Platform · in the page
agents-and-tools/tool-use/text-editor-tool
…red at the end of statements that start a new code block, such as for loops, if statements, function definitions, etc. Without the colon, Python raises a syntax error because it doesn't know where the…
Log at info level
Claude Developer Platform · in the page
agents-and-tools/tool-use/tool-runner
…an end the loop at any iteration with a `break` statement. The runner loops until Claude returns a message without a tool use, or until it reaches `max_iterations` (csharp, php: `maxIterations`; java:…
Retrieve Message Batch results
Claude Developer Platform · in the page
api/beta/messages/batches/results
…- Understand token accumulation across server-side tool use loops A `compaction` entry reports the token usage of the compaction operation itself — the server-side request that…
files
Claude Developer Platform · in the page
build-with-claude/files
…beta names. 2. **Update pagination.** Replace `after_id`/`before_id` loops with the `page`/`next_page` cursor, or use the SDK auto-pagination helpers shown in [Managing files](https://platform.claude…
message-threads
Claude Developer Platform · in the page
build-with-claude/message-threads
…d steadier as the conversation grows. Threads help most in long agent loops. Without a thread, every turn uploads the whole conversation again, and the API validates and tokenizes all of it again. Wit…
mid-conversation-effort-example
Claude Developer Platform · in the page
build-with-claude/mid-conversation-effort-example
…without launching it all at once. The `DOC_TEST_MODE` check caps the loops to a single turn when that environment variable is set, so the automated docs harness can validate that the file compiles an…
claude-prompting-best-practices
Claude Developer Platform · in the page
build-with-claude/prompt-engineering/claude-prompting-best-practices
…, passing thinking blocks back unchanged, tool-call batching in agent loops, search triggering at low effort, formatting, and writing density. | | Claude Fable 5 and Claude Mythos 5 | [Prompting Claud…
Delivering work
Claude Developer Platform · in the page
build-with-claude/prompt-engineering/prompting-claude-fable-5-1
…-user-facing-progress-updates) * One tool call for each turn in agent loops: [Batch independent tool calls in agent loops](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prom…
prompting-claude-opus-5
Claude Developer Platform · in the page
build-with-claude/prompt-engineering/prompting-claude-opus-5
…. The turn completes normally and the call never runs, and in agentic loops the leaked text stays in the conversation history, so later turns are affected as well. This is most common on tool-heavy wo…
prompting-claude-sonnet-5
Claude Developer Platform · in the page
build-with-claude/prompt-engineering/prompting-claude-sonnet-5
…onnet 4.6 by default and reaches for tools and runs self-verification loops more readily. With thinking disabled, the model is less likely to reach for tools or consider searching; if you rely on tool…
task-budgets
Claude Developer Platform · in the page
build-with-claude/task-budgets
…ng `remaining` on every request, not only the one that compacts. For loops that resend the full uncompacted history on every request, omit `remaining` and let the server track the countdown. ## Chan…
thinking-troubleshooting
Claude Developer Platform · in the page
build-with-claude/thinking-troubleshooting
…gs in its visible text. A leaked tool call never runs, and in agentic loops the leaked text stays in the conversation history, so later turns are affected as well. This occurs on Claude Opus 5 when t…
working-with-messages
Claude Developer Platform · in the page
build-with-claude/working-with-messages
…s that runs in managed infrastructure | | **Best for** | Custom agent loops and fine-grained control | Long-running tasks and asynchronous work | This guide covers common patterns for working with th…
intro
Claude Developer Platform · in the page
intro
…s that runs in managed infrastructure | | **Best for** | Custom agent loops and fine-grained control | Long-running tasks and asynchronous work | To learn more about each, see [Using the Messages API…
workload-identity-federation
Claude Developer Platform · in the page
manage-claude/workload-identity-federation
…a fresh JWT for each exchange instead of reusing a cached one. Retry loops are the usual cause of reuse. The SDK rereads `ANTHROPIC_IDENTITY_TOKEN_FILE` on every exchange, so the file must hold a new…
agent-setup
Claude Developer Platform · in the page
managed-agents/agent-setup
…d default for interactive callers. Omitting it fits declarative apply loops where the loop owns the agent, such as a CI job that syncs checked-in agent definitions. * **Omitted fields are preserved.*…
DCF Model Rubric
Claude Developer Platform · in the page
managed-agents/define-outcomes
…mitted for outcome-oriented sessions and show the number of iteration loops and the grader’s feedback process. * You can also send `user.message` [events](https://platform.claude.com/docs/en/managed-a…
overview
Claude Developer Platform · in the page
managed-agents/overview
…s that runs in managed infrastructure | | **Best for** | Custom agent loops and fine-grained control | Long-running tasks and asynchronous work | Claude Managed Agents provides the harness and infras…
migration-guide
Claude Developer Platform · in the page
models/opus-5-5/migration-guide
…ng stream events. 3. **Return thinking blocks unmodified in tool-use loops:** If you run a tool-use loop, pass the `thinking` blocks from each assistant response back to the API complete and unmodifi…
whats-new-opus-5-5
Claude Developer Platform · in the page
models/opus-5-5/whats-new-opus-5-5
…n by position, and pass `thinking` blocks back unmodified in tool-use loops. Code that already runs on Claude Opus 5 with thinking on needs no change. See [Thinking](https://platform.claude.com/docs/e…
migration-guide
Claude Developer Platform · in the page
models/sonnet-5-5/migration-guide
…text` breaks. * **Pass `thinking` blocks back unchanged** in tool-use loops, including empty ones. See [Preserving thinking blocks](https://platform.claude.com/docs/en/build-with-claude/thinking#prese…
overview
Claude Developer Platform · in the page
release-notes/overview
…ext-watermark). ### November 2, 2026 * Long conversations and agent loops on the Messages API can now send smaller requests and get a lower time to first token with [message threads](https://platfor…
How the agent loop works
Claude Code CLI · in the page
agent-sdk/agent-loop
…docs/en/how-claude-code-works.md). For a practical guide to designing loops in Claude Code, from turn-based to goal-based and proactive loops, see [Loop engineering: getting started with loops](https:…
Intercept and control agent behavior with hooks
Claude Code CLI · in the page
agent-sdk/hooks
…aude.com/docs/en/sub-agents.md#permission-modes). ### Recursive hook loops with subagents A `UserPromptSubmit` hook that spawns subagents can create infinite loops if those subagents trigger the sam…
Troubleshoot the Agent SDK
Claude Code CLI · in the page
agent-sdk/troubleshooting
…le in Python, subagent permission prompts multiplying, recursive hook loops with subagents, `systemMessage` not appearing in output | [Fix common issues](https://code.claude.com/docs/en/agent-sdk/hook…
Handle approvals and user input
Claude Code CLI · in the page
agent-sdk/user-input
…d routes to a dedicated handler 2. **Display questions**: The handler loops through the `questions` array and prints each question with numbered options 3. **Collect input**: The user can enter a numb…
Best practices for Claude Code
Claude Code CLI · in the page
best-practices
…ts, which is how Claude Code ends up in CI jobs, git hooks, and shell loops. In a script you'll almost always want a few more flags: * [`--bare`](https://code.claude.com/docs/en/headless#start-faste…
Claude Code changelog
Claude Code CLI · in the page
changelog
…, or RAM use growing without end, when the memory folder held symlink loops, and a hang when it held a named pipe * \[VSCode] Fixed a running command's live output stopping after one failed read * \[V…
Manage costs effectively
Claude Code CLI · in the page
costs
…h the fix shortcut](#apply-recommendations-with-the-fix-shortcut) * **Loops**: a row for each of the heaviest [`/loop` or other session-scoped scheduled tasks](https://code.claude.com/docs/en/schedule…
Message your other Claude Code sessions
Claude Code CLI · in the page
cross-session-messaging
…tells Claude to batch the rest into one message or wait. * **Message loops are throttled**: in the receiving session, Claude Code rate-limits repeated messages per sender, drops identical repeats arr…
Extend Claude Code
Claude Code CLI · in the page
features-overview
…gents](https://code.claude.com/docs/en/sub-agents.md)** run their own loops in isolated context, returning summaries * **[Dynamic workflows](https://code.claude.com/docs/en/workflows.md)** run many su…
Hooks reference
Claude Code CLI · in the page
hooks
…after a normalization exits without touching the file. A looser guard loops forever, because `perl -i` rewrites the file even when it substitutes nothing and Claude Code runs the hook again after ever…
Configure permissions
Claude Code CLI · in the page
permissions
…*Writes to special shell variables**: a command that sets, unsets, or loops over certain special shell variables, such as `PATH` or `IFS`, prompts even when the rest of the command is read-only. * **C…
Mods reference
Claude Code CLI · in the page
plugins/mods/reference
…de Code v2.1.299 or later. | | Scopes, such as functions, blocks, and loops, nested inside one another in one file of a hooks module | 2,000 | | Command, tool, subagent type, and pane names, the `id`…
Troubleshoot a mod
Claude Code CLI · in the page
plugins/mods/troubleshoot
…e in a hooks module can't nest scopes, such as functions, blocks, and loops, more than [2,000 deep](https://code.claude.com/docs/en/plugins/mods/reference.md#limits). [`claude plugin validate`](https:…
Troubleshooting
Claude Code CLI · in the page
troubleshooting
…ude.com/docs/en/troubleshoot-install.md#auto-update-failed) | | Login loops, OAuth errors, `403 Forbidden`, "organization disabled", Amazon Bedrock, Google Cloud's Agent Platform, or Microsoft Foundry…
Orchestrate subagents at scale with dynamic workflows
Claude Code CLI · in the page
workflows
…telling the script | | 1,000 agents total per run | Prevents runaway loops | ## Manage runs Once a run starts, you manage it from the `/workflows` view, or by expanding its progress line in the tas…
Performance and limits
Claude Documentation · in the page
office-agents/performance
…-ref-4-a) [b](#cite-ref-4-b) “[Avoid using the context.sync method in loops](https://learn.microsoft.com/en-us/office/dev/add-ins/concepts/correlated-objects-pattern)”. *Microsoft Learn*. “Office supp…
Use Claude for M365 with third-party platforms
Claude Documentation · in the page
office-agents/third-party-platforms
…on failures, an add-in that does not appear, sign-in or admin-consent loops, and reading the add-in's error paste. | | `/claude-for-msft-365-install:export-data` | Makes a read-only copy of a user's c…
Agents Charter
Model Context Protocol · in the page
community/interest-groups/agents
…vents WG. The charter does not predetermine where inference or agent loops run, or whether a particular capability belongs in Tasks, an Agents Extension, or existing MCP primitives. The IG evaluates…
MCP Apps Working Group Charter
Model Context Protocol · in the page
community/working-groups/apps
…onsibility of their authors. * **General agent orchestration**: Agent loops and sub-agent coordination belong to the Agents IG, and task management belongs to the Tasks and Events WG. This WG covers o…
Client Best Practices
Model Context Protocol · in the page
docs/2024-11-05/develop/clients/client-best-practices
…ct a typed result using a fast model**, for single-shot calls outside loops. Expose a host-brokered `extract(value, ExpectedType)` helper through the same stub-interception path as MCP tool calls so t…
Security Best Practices
Model Context Protocol · in the page
docs/2024-11-05/tutorials/security/security_best_practices
…WW-Authenticate`) * Cache recent failures to avoid repeated elevation loops for denied scopes #### Common Mistakes * Publishing all possible scopes in `scopes_supported` * Using wildcard or omnibu…