Skip to content

Bump condenser defaults: max_size 120->240#12267

Merged
xingyaoww merged 3 commits intomainfrom
bump-condenser-defaults
Jan 6, 2026
Merged

Bump condenser defaults: max_size 120->240#12267
xingyaoww merged 3 commits intomainfrom
bump-condenser-defaults

Conversation

@xingyaoww
Copy link
Copy Markdown
Collaborator

@xingyaoww xingyaoww commented Jan 5, 2026

Description

This PR updates the condenser defaults for existing users to address the staling issue in V1 conversations.

Changes

  1. Database Migration (086):

    • Updates existing users with condenser_max_size=120 to 240
    • Adds new condenser_keep_first column to user_settings table
    • Sets condenser_keep_first=4 for existing users who have condenser settings
  2. Model Updates:

    • Added condenser_keep_first field to Settings data model
    • Added validator for condenser_keep_first (must be non-negative)
    • Added condenser_keep_first column to enterprise UserSettings table
  3. Code Updates:

    • Updated _create_condenser method to accept and use condenser_keep_first parameter
    • Updated _create_agent_with_context to pass condenser_keep_first from user settings
    • Fixed outdated comment about SDK defaults (was incorrectly stating 120/4, now correctly states 240/2)

Background

The SDK has defaults of max_size=240 and keep_first=2, but existing users who had the old default of max_size=120 stored in the database were not benefiting from the increased default. This migration updates those users to the new values and adds support for customizing keep_first.

Testing

  • Migration tested locally
  • Pre-commit hooks pass

Related Issues

Addresses staling issues in V1 conversations by increasing the condenser history size.

@xingyaoww can click here to continue refining the PR


To run this PR locally, use the following command:

GUI with Docker:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.openhands.dev/openhands/runtime:82e221e-nikolaik   --name openhands-app-82e221e   docker.openhands.dev/openhands/openhands:82e221e

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 5, 2026

⚠️ This PR contains migrations. Please synchronize before merging to prevent conflicts.

Comment thread enterprise/migrations/versions/086_bump_condenser_defaults.py Outdated
@xingyaoww xingyaoww marked this pull request as ready for review January 6, 2026 20:09
@xingyaoww xingyaoww changed the title Bump condenser defaults: max_size 120->240, add keep_first=4 Bump condenser defaults: max_size 120->240 Jan 6, 2026
Copy link
Copy Markdown
Collaborator

@malhotra5 malhotra5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 6, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  openhands/app_server/app_conversation
  app_conversation_service_base.py
  openhands/server/session
  session.py
Project Total  

This report was generated by python-coverage-comment-action

@openhands-ai
Copy link
Copy Markdown

openhands-ai Bot commented Jan 6, 2026

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • Docker

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #12267 at branch `bump-condenser-defaults`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

@all-hands-bot
Copy link
Copy Markdown
Collaborator

Feature deployment is available at: https://ohpr-12267.staging.all-hands.dev
Redirect URI for GitHub App is https://ohpr-12267.auth.staging.all-hands.dev/realms/allhands/broker/github/endpoint
Last updated: Jan 06, 2026, 03:21:43 PM ET

@xingyaoww
Copy link
Copy Markdown
Collaborator Author

@OpenHands please check datadog API for logs - looks like the DB migration didn't work for https://ohpr-12267.staging.all-hands.dev/

I still see 120 max history size in the UI, any idea?

@openhands-ai
Copy link
Copy Markdown

openhands-ai Bot commented Jan 6, 2026

I'm on it! xingyaoww can track my progress at all-hands.dev

@xingyaoww xingyaoww requested a review from amanape as a code owner January 6, 2026 20:39
@openhands-ai
Copy link
Copy Markdown

openhands-ai Bot commented Jan 6, 2026

Summary

I investigated the issue using the Datadog API and found the root cause of why you're still seeing 120 in the UI despite the migration running.

Root Cause Analysis

From the Datadog logs, I confirmed that:

  1. The migration DID run at 2026-01-06T20:21:08.235Z on the staging deployment (Running upgrade 085 -> 086, bump condenser defaults: max_size 120->240)
  2. The migration only updated rows where condenser_max_size == 120, but most users have NULL in the database
  3. The application code defaults NULL to 120 in both frontend (DEFAULT_SETTINGS.condenser_max_size: 120) and backend (settings.condenser_max_size or 120)

So users with NULL in the database were not updated by the migration, and the UI showed 120 because that's the fallback default.

Fix Applied

I pushed a commit that:

  1. Updated the migration to also update NULL values to 240:

    # Update users with NULL value (which defaulted to 120 in application code)
    op.execute(
        user_settings_table.update()
        .where(user_settings_table.c.condenser_max_size.is_(None))
        .values(condenser_max_size=240)
    )
  2. Updated frontend default from 120 to 240 in frontend/src/services/settings.ts

  3. Updated backend default from 120 to 240 in openhands/server/session/session.py (V0 code)

  4. Updated test comments to reflect correct SDK defaults (240/2 instead of 120/4)

Next Steps

Once the staging deployment redeploys with this fix, the migration will:

  • Update all users with condenser_max_size = 120 to 240
  • Update all users with condenser_max_size = NULL to 240

And new users will get 240 as the default instead of 120.

The changes have been pushed to the bump-condenser-defaults branch.

View full conversation

@all-hands-bot
Copy link
Copy Markdown
Collaborator

Feature deployment is available at: https://ohpr-12267.staging.all-hands.dev
Redirect URI for GitHub App is https://ohpr-12267.auth.staging.all-hands.dev/realms/allhands/broker/github/endpoint
Last updated: Jan 06, 2026, 03:55:22 PM ET

@xingyaoww
Copy link
Copy Markdown
Collaborator Author

@OpenHands please fix these - we should set default value to 240 in FE and backend as well including the test

The application code defaults NULL to 120 in both frontend (DEFAULT_SETTINGS.condenser_max_size: 120) and backend (settings.condenser_max_size or 120)

@openhands-ai
Copy link
Copy Markdown

openhands-ai Bot commented Jan 6, 2026

I'm on it! xingyaoww can track my progress at all-hands.dev

- Add migration 086 to update existing users with condenser_max_size=120 to 240
- Add new condenser_keep_first column to user_settings table
- Set condenser_keep_first=4 for existing users who have condenser settings
- Update Settings model with condenser_keep_first field and validator
- Update _create_condenser to accept and use condenser_keep_first parameter
- Fix outdated comment about SDK defaults (was 120/4, now 240/2)

Co-authored-by: openhands <openhands@all-hands.dev>
…or keep_first

Remove condenser_keep_first column and related code since the SDK default
will be used automatically when the column is not present.

Co-authored-by: openhands <openhands@all-hands.dev>
The migration was only updating rows where condenser_max_size=120, but most
users have NULL in the database (which defaulted to 120 in application code).

Changes:
- Migration now updates both condenser_max_size=120 AND NULL values to 240
- Updated frontend default from 120 to 240
- Updated backend default from 120 to 240 (V0 session.py)
- Updated test comments to reflect correct SDK defaults (240/2)

Co-authored-by: openhands <openhands@all-hands.dev>
@xingyaoww xingyaoww force-pushed the bump-condenser-defaults branch from 89ead3f to 82e221e Compare January 6, 2026 20:59
@openhands-ai
Copy link
Copy Markdown

openhands-ai Bot commented Jan 6, 2026

I've fixed the failing GitHub Action by rebasing the bump-condenser-defaults branch on top of the latest main branch.

Issue: The check-sync action was failing because the base branch (main) was not an ancestor of the PR branch. This happens when new commits are pushed to main after the PR branch was created.

Fix: Rebased the PR branch on top of origin/main:

  • The branch now includes the latest commit from main: 1907ebeaa feat: add chat message skeletons and improve routing stability (#12223)
  • Force-pushed the rebased branch to update the PR

The PR should now pass the check-sync action. You can monitor the new workflow run at: #12267

View full conversation

@xingyaoww xingyaoww added deploy and removed deploy labels Jan 6, 2026
@all-hands-bot
Copy link
Copy Markdown
Collaborator

Feature deployment is available at: https://ohpr-12267.staging.all-hands.dev
Redirect URI for GitHub App is https://ohpr-12267.auth.staging.all-hands.dev/realms/allhands/broker/github/endpoint
Last updated: Jan 06, 2026, 04:13:57 PM ET

@xingyaoww xingyaoww requested a review from malhotra5 January 6, 2026 21:18
@xingyaoww
Copy link
Copy Markdown
Collaborator Author

@OpenHands check datadog, i got these error when i open the deployment:

400 Bad Request
Request Header Or Cookie Too Large
nginx/1.29.4

@openhands-ai
Copy link
Copy Markdown

openhands-ai Bot commented Jan 6, 2026

I'm on it! xingyaoww can track my progress at all-hands.dev

@all-hands-bot
Copy link
Copy Markdown
Collaborator

Feature deployment is available at: https://ohpr-12267.staging.all-hands.dev
Redirect URI for GitHub App is https://ohpr-12267.auth.staging.all-hands.dev/realms/allhands/broker/github/endpoint
Last updated: Jan 06, 2026, 04:20:25 PM ET

@openhands-ai
Copy link
Copy Markdown

openhands-ai Bot commented Jan 6, 2026

Summary

I investigated the "400 Bad Request - Request Header Or Cookie Too Large" error you're experiencing when opening the deployment at https://ohpr-12267.staging.all-hands.dev using the Datadog API.

Findings

  1. The error is NOT appearing in Datadog logs - This is expected because the 400 error happens at the nginx/ingress level before the request reaches the application, so it doesn't get logged to the application logs.

  2. Related Keycloak errors found - I did find authentication errors in the logs:

    Redirection URL does not contain a state parameter. providerId=github, 
    redirectionUrl=https://ohpr-12267.auth.staging.all-hands.dev/realms/allhands/broker/github/endpoint
    

    This suggests the OAuth state parameter is being lost, likely due to the cookie size issue.

Root Cause

The "Request Header Or Cookie Too Large" error is a client-side browser issue, not a code problem. It happens when:

  • Too many cookies have accumulated for the *.staging.all-hands.dev domain
  • Each PR deployment (ohpr-XXXXX) creates its own set of authentication cookies
  • Over time, testing multiple PR deployments causes cookie accumulation that exceeds nginx's header size limit

Solution

To fix this immediately:

  1. Clear cookies for *.staging.all-hands.dev and *.all-hands.dev domains in your browser
  2. Or try accessing the deployment in an incognito/private browser window

This is not a bug in the PR code - it's a common issue when testing multiple staging deployments that share a parent domain. No code changes are needed.

View full conversation

@xingyaoww
Copy link
Copy Markdown
Collaborator Author

OK! Confirmed this is fixed.

#12267 (comment) -> this issue is just a blip

image

Copy link
Copy Markdown
Collaborator

@malhotra5 malhotra5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@xingyaoww xingyaoww merged commit af5c227 into main Jan 6, 2026
30 checks passed
@xingyaoww xingyaoww deleted the bump-condenser-defaults branch January 6, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants