> ## Documentation Index
> Fetch the complete documentation index at: https://docs.replit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent and AI

> Answers to common Agent questions—fixing a frozen or looping Agent, reducing costs, Agent modes, rolling back changes, and using your own API keys.

These answers cover working with Agent. For full reference, see the [Agent overview](/references/agent/overview), [Agent modes](/references/agent/agent-modes), and [AI billing](/billing/ai-billing).

<AccordionGroup>
  <Accordion title="Agent is frozen or keeps disconnecting—how do I fix it?">
    1. Open the **Shell** pane in your project—not the Agent chat.
    2. Type `kill 1` and press Enter to stop the frozen process. (`kill 1` is safe in Replit—it restarts your project's main process, it doesn't delete anything.)
    3. Open a new Agent chat and describe your task again to continue.

    While Agent looks frozen, stop sending messages—extra messages create conflicting instructions. If Agent keeps freezing on the same task, break the work into smaller, focused prompts.
  </Accordion>

  <Accordion title="Agent is looping or repeating the same steps—how do I stop it?">
    1. Select **Stop** in the Agent panel to halt it immediately.
    2. Open the **Shell** pane (not the Agent chat), type `kill 1`, and press Enter.
    3. Open a new Agent chat and rephrase your task more specifically.

    To avoid loops:

    * Break large tasks into smaller prompts—one goal per message.
    * Turn on [Code Optimizations](/references/agent/code-optimizations).
    * Set a usage limit in [Managing your spend](/billing/managing-spend) so a loop can't run up a large bill.
  </Accordion>

  <Accordion title="How do I reduce Agent costs—what settings actually help?">
    Three settings make the biggest difference:

    * **[Economy mode](/references/agent/agent-modes)**—uses fewer credits per task and is a good default for everyday builds.
    * **[Code Optimizations](/references/agent/code-optimizations)**—Agent reviews and simplifies its own code, reducing costly rework.
    * **Usage limit and budget**—set a hard cap in [Managing your spend](/billing/managing-spend).

    It also helps to start a new Agent chat when you switch tasks and use [Plan mode](/references/agent/plan-mode) to scope work first. Check your usage dashboard to see which tasks cost the most.
  </Accordion>

  <Accordion title="What are the Agent modes, and how do they differ?">
    Agent has three top-level modes plus an optional speed toggle. See [Agent modes](/references/agent/agent-modes) for full guidance.

    * **Lite**—fast, lightweight models for quick, scoped edits.
    * **Economy**—optimized for cost; a strong default for everyday builds.
    * **Power**—the most capable models for complex tasks and larger codebases.
    * **Turbo**—a toggle in Advanced settings, available in Power mode, that runs the fastest models. It's significantly faster but costs more, so use it intentionally.

    Separately, [Plan mode](/references/agent/plan-mode) lets Agent scope work before making changes, while Build mode applies changes directly. See [Plan vs. Build mode](/learn/plan-vs-build-mode). All modes use credits, including Plan mode reasoning.
  </Accordion>

  <Accordion title="Agent made changes I didn't want—how do I roll back?">
    Replit saves [checkpoints](/references/version-control/checkpoints-and-rollbacks) as Agent works. In the Agent chat, find the message before the change you want to undo and select the rollback option next to it to restore your project to that point.

    For full rollback options—including recovering specific files and live deployments—see [Checkpoints and rollbacks](/references/version-control/checkpoints-and-rollbacks).
  </Accordion>

  <Accordion title="Agent says it can't access the internet or external APIs—is that expected?">
    During the build and edit phase, Agent works in a sandboxed environment with restricted outbound access. Your deployed app can still make external API calls when it runs—the sandbox applies to Agent's editing environment, not your running app.

    If an API call fails in your running app, confirm your keys are saved in the [Secrets](/core-concepts/project-editor/app-setup/secrets) pane, then check the provider's status page. On a corporate or school network, outbound connections from your app may be blocked—check with your network admin.
  </Accordion>

  <Accordion title="Can I use my own API keys with Agent?">
    Yes. Add your keys to the [Secrets](/core-concepts/project-editor/app-setup/secrets) pane and your app uses them for its API calls. Open the **Secrets** tool, select **+ New secret**, and enter a name (such as `OPENAI_API_KEY`) and value.

    You can [bring your own AI provider keys](/references/integrations/replit-ai-integrations) for the models your app calls. The model that powers the Agent experience itself runs on Replit's infrastructure and can't be swapped.
  </Accordion>

  <Accordion title="Agent keeps adding features I didn't ask for—how do I get more precise behavior?">
    Keep Agent focused with tighter prompts:

    * Start with the word *Only*—for example, "Only add a delete button to the user card. Don't change anything else."
    * Use [Plan mode](/references/agent/plan-mode) first to review what Agent intends to do before it changes anything.
    * If Agent makes an unwanted change, ask it to undo that change in the same chat right away.

    For more, see [Effective prompting](/learn/effective-prompting).
  </Accordion>
</AccordionGroup>

## Still need help?

If your Agent question isn't answered here, [contact Replit Support](https://replit.com/support).
