Repository navigation
fix(condenser): Forgetting range calculation interprets keep_first correctly - #1708
Conversation
|
Hi! I started running the condenser tests on your PR. You will receive a comment with the results shortly. Note: These are non-blocking tests that validate condenser functionality across different LLMs. |
all-hands-bot
left a comment
There was a problem hiding this comment.
Review Summary
The fix correctly addresses the off-by-one error in the forgetting range calculation by changing strict=True to strict=False. This ensures that keep_first=N properly means "keep the first N events" (indices 0 to N-1) and start forgetting from index N.
✅ What's Good
- Core fix is correct: Changing from
strict=True(find index > keep_first) tostrict=False(find index >= keep_first) properly fixes the off-by-one error - Consistency: The change makes
forgetting_startconsistent withforgetting_end, which already usesstrict=False - Test updates are accurate: All three test updates correctly reflect the new behavior with proper arithmetic
- Comment updates: The inline comment is correctly updated from "> keep_first" to ">= keep_first"
🟡 Minor Suggestions
-
Documentation: Consider adding a docstring to the
keep_firstfield (line 45) to clarify its meaning: "Number of events to keep from the start before condensation begins". This would help prevent future confusion about its interpretation. -
Edge case testing: While the fix should handle boundary conditions correctly (e.g.,
keep_first=0), consider adding explicit tests for these edge cases to increase confidence in the implementation.
Verification
I verified that:
- The validation logic in
validate_keep_first_vs_max_size()remains correct with the new interpretation - The formula
keep_first + 1 + events_from_tail = target_sizestill holds - No other parts of the codebase use
find_next_manipulation_index()that would be affected by this change - The arithmetic in all test comments is accurate
Overall, this is a solid bug fix that correctly addresses issue #1701. The suggestions above are optional enhancements for documentation and test coverage.
Condenser Test Results (Non-Blocking)
🧪 Condenser Tests ResultsOverall Success Rate: 71.4% 📊 Summary
📋 Detailed Resultslitellm_proxy_gpt_5.1_codex_max
Skipped Tests:
Failed Tests:
litellm_proxy_anthropic_claude_opus_4_5_20251101
Failed Tests:
|
| # Find actual forgetting_start: smallest manipulation index >= keep_first | ||
| forgetting_start = view.find_next_manipulation_index( | ||
| self.keep_first, strict=True | ||
| self.keep_first, strict=False |
There was a problem hiding this comment.
Just a tiny thought, this seems a bit strange to me. I expected we will fix some > into a >=, but maybe I'm missing the reason for strict?
There was a problem hiding this comment.
That's the reason. Instead of expecting the first manipulation index to be strictly greater than keep_first, it can now be greater than or equal to.
Although I can't quite remember why it was strict in the first place. Not sure there was ever a particular reason.
There was a problem hiding this comment.
It feels like maybe it was a bug to be strict, and if so, maybe we could simplify it sometime, maybe giving up strict from signature if it doesn't seem really useful.
enyst
left a comment
There was a problem hiding this comment.
LGTM, I have a tiny confusion but it's not important, thank you!
|
Hi! I started running the condenser tests on your PR. You will receive a comment with the results shortly. Note: These are non-blocking tests that validate condenser functionality across different LLMs. |
Condenser Test Results (Non-Blocking)
🧪 Condenser Tests ResultsOverall Success Rate: 100.0% 📊 Summary
📋 Detailed Resultslitellm_proxy_anthropic_claude_opus_4_5_20251101
litellm_proxy_gpt_5.1_codex_max
Skipped Tests:
|
|
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
|
@csmith49 Just a quick note, since I just noticed:
It supports reasoning effort. Not "extended thinking" since that's Anthropic's equivalent of reasoning effort -ish (kind of), but the OpenAI reasoning effort that almost every other reasoning LLM provider supports. |
…correctly (OpenHands#1708) Co-authored-by: Calvin Smith <calvin@all-hands.dev>

Summary
Slightly modifies calculations on which range of events to forget during condensation.
The starting point of the forgetting range was previously "strict" -- this caused the condenser to look for the manipulation index greater than the
keep_firstvalue. But this produces an off-by-one error on the interpretation ofkeep_first, so some legit condensation ranges were being ignored.Fixes #1701.
Checklist
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:a5d6d91-pythonRun
All tags pushed for this build
About Multi-Architecture Support
a5d6d91-python) is a multi-arch manifest supporting both amd64 and arm64a5d6d91-python-amd64) are also available if needed