Skip to content

Agent mode gets stuck after model context limit is reached instead of recovering gracefully #2063

Description

Issue Type

Both / Not sure

Operating System

Linux

Description of the bug

When using a model through a provider in BrowserOS (especially in Agent Mode), if the model reaches its maximum context length/token limit, the current browser tasks continue running even though the LLM can no longer process requests.

Instead of handling this gracefully, BrowserOS repeatedly shows errors such as:

  • Failed to fetch
  • Upstream error
  • Context length exceeded
  • Rate limit (depending on the provider)

Since every model has a different maximum context window, BrowserOS should be aware of the model's context usage and provide a better recovery experience.

Steps to Reproduce

  1. Open BrowserOS and start a new Agent Mode or Chat Mode session.

  2. Configure a provider (I tested with OpenCode API using DeepSeek V4 Flash, and also observed the same behavior with GPT-5.4).

  3. Continue the conversation or run long-running browser/agent tasks until the model reaches its maximum context window.

  4. Once the context limit is exceeded, let the agent continue running.

  5. Observe that BrowserOS continues issuing requests while browser tasks remain active, repeatedly returning errors such as:

    • Failed to fetch
    • Upstream error
    • Context length exceeded
    • Rate limit (provider-dependent)

Note: This appears to be especially noticeable with medium-context models, where long-running agent workflows exhaust the available context more quickly. Since different models/providers expose different context window sizes, BrowserOS should ideally track context usage and recover gracefully rather than continuing to execute tasks that are guaranteed to fail.

Screenshots / Videos

No response

BrowserOS Version

148.0.7948.97

Additional Context

Expected behavior:

  • Display the current context/token usage for the active conversation.
  • Warn the user when they're approaching the model's context limit.
  • Automatically compact or summarize the conversation when appropriate.
  • Provide a "Start a new context while keeping task memory" or "Compact context" option in both Chat Mode and Agent Mode.
  • Pause or retry browser tasks gracefully instead of letting them continue to fail with repeated upstream/fetch errors.

This would significantly improve long-running agent workflows and prevent unnecessary task failures caused solely by exhausted context windows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GitHubbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions