Skip to content

Wrong agent used after compaction #4546

Closed

Description

@conradkoh

Description

When compaction happens, it resets the model to the build agent. This problem is aggravated because the switching of the agent might grant it access to extra tools or have missing tools that it was supposed to have to perform the task.

For example, I have a browse agent that has access to the browser. The build tool does not. Halfway while browsing, after compaction, the tool reverts to the build tool and starts using webfetch instead, giving nonsense results in the research.

OpenCode version

1.0.80

Steps to reproduce

  1. Create a browse agent
  2. Use it to access the browser
  3. When compaction happens, the build agent is used
  4. The continued task is now executed using the build agent

Screenshot and/or share link

No response

Operating System

Tahoe 26.1

Terminal

VSCode

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Nov 20, 2025
  2. conradkoh commented on Nov 20, 2025

    @conradkoh
    Author

    This might be a duplicate of #3099 but I'm not sure if it is exactly the same. That one is about the AGENTS.md, this one is that wrong agent itself is being used after compaction.

  3. emincangencer commented on Nov 20, 2025

    @emincangencer

    Something similar happens. /compact command creates next steps from the chat history and build agent gets triggered to do them. Expected behavior should be to disable any action after compact report is given. there's:

    `

    User

    `
    Which shouldn't exist there, clearly it thinks user made an action, but there was none.

    Chat:
    `

    Assistant

    Summary of Conversation

    What Was Done

    • Tamagui Setup for Expo: Installed Tamagui packages (tamagui, @tamagui/config, @tamagui/babel-plugin, etc.) and configured the app for Expo. This included creating babel.config.js for Babel plugin integration, tamagui.config.ts with default Tamagui configuration, and tamagui-web.css for web styles. Updated tsconfig.json to include Tamagui types and wrapped the root layout (app/_layout.tsx) with TamaguiProvider.
    • Component Refactoring: Updated components/themed-text.tsx and components/themed-view.tsx to use Tamagui's Text and View components instead of React Native's, leveraging Tamagui's theming for consistency.
    • App Screen Updates: Refactored app/(tabs)/index.tsx to use Tamagui components like YStack, Card, and Button, replacing old styled views. Simplified the home screen to a clean "Welcome to the Starter Kit" layout with a centered button, removing the parallax scroll, React logo, and edit instructions. Updated app/modal.tsx to use Tamagui's View instead of React Native's.
    • Navigation Changes: Modified app/(tabs)/_layout.tsx to hide the bottom tab bar (tabBarStyle: { display: 'none' }) for a web-app-like layout. Removed the explore tab and deleted app/(tabs)/explore.tsx.
    • Git Management: Staged all changes, unstaged the generated .tamagui/tamagui.config.json file, added .tamagui/ to .gitignore to exclude generated configs, and committed the relevant files.

    What Is Currently Being Worked On

    • The Expo app is fully set up with Tamagui as the UI framework, with navigation hidden and a minimal starter kit home screen. No active modifications in progress; the app is in a ready state for further development.

    Which Files Were Modified/Created

    • Created: babel.config.js, tamagui.config.ts, tamagui-web.css.
    • Modified: package.json (added dependencies), tsconfig.json (added types), app/_layout.tsx (added TamaguiProvider), app/(tabs)/_layout.tsx (hid tabs), app/(tabs)/index.tsx (refactored to Tamagui layout), app/modal.tsx (updated to Tamagui View), components/themed-text.tsx and components/themed-view.tsx (refactored to Tamagui components), .gitignore (added .tamagui/).
    • Deleted: app/(tabs)/explore.tsx.
    • Unstaged/Ignored: .tamagui/tamagui.config.json (generated file, now ignored).

    What Needs to Be Done Next

    • The app is now a clean Tamagui-based starter kit. Potential next steps include adding custom navigation (e.g., a sidebar or header menu), integrating more Tamagui components, implementing routing for additional screens, or building out features like forms, data fetching, or authentication. If you have a specific direction (e.g., adding a new page or feature), let me know to continue development. Run expo start to test the current setup.

    User


    Assistant

    Tool: read
    

    Assistant

    Tool: read
    

    Assistant

    Tool: write
    

    Assistant

    Tool: read
    

    Assistant

    Tool: edit
    

    Assistant

    Tool: read
    

    Assistant

    Tool: read
    

    Assistant

    Tool: read
    

    Assistant

    Tool: read
    

    Assistant

    Tool: edit
    

    Assistant


    `

    I canceled after that.

  4. wolfie82 commented on Nov 20, 2025

    @wolfie82
    Contributor

    I believe this is related to #4475 and #4431

  5. rekram1-node commented on Nov 21, 2025

    @rekram1-node
    Collaborator

    Should be fixed in next release

  6. jcowles commented on Jan 12, 2026

    @jcowles

    I just pulled latest and can confirm that this is fixed in the simple case, but is still happening when the sub-agent accidentially overruns the context size:

    When this error occurs:

    litellm.ContextWindowExceededError: litellm.BadRequestError: ContextWindowExceededError: OpenAIException - This model's maximum context length is 32000 tokens. However, your request has 56121 input tokens. Please reduce the length of the input messages. (parameter=input_tokens, value=56121) None
    model=glm-4.7-fp8. context_window_fallbacks=None. fallbacks=None.
    Set 'context_window_fallback' - https://docs.litellm.ai/docs/routing#fallbacks. Received Model Group=glm-4.7-fp8
    Available Model Group Fallbacks=None
    

    After this error, it continues processing in the primary agent context, as reported in the bug above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions