<@U080DD1FR4K> sadly, another condensation corner ...
# proj-agent
c
@wide-doctor-37830 sadly, another condensation corner cases 😞 Do you think if we can implement a mechanism where we do compact similar to claude-code (instead of reduce events by half, we can just condense everything into one new message) 👀 https://github.com/OpenHands/software-agent-sdk/issues/1518#issuecomment-3695021678
➕ 1
w
We can tweak the condensation triggers to get something like what Claude Code does if we need to, yeah. There are other fixes I'd like to try first if possible though: • Parameter tweaking: the
keep_first
setting we inherited from v0 is not quite the behavior we want -- in the case of the event dump it's trying to keep the first few messages in the tool loop, but it can't start a condensation in the middle of one so it fails. We could lower
keep_first
to just keep up to the first user message, and/or raise
max_size
so we're likely to actually get a full tool loop in before condensation. • Delay condensation: in the case that we hit one of our condensation triggers (tokens/events) but can't actually forget anything, put the condensation on hold until the first opportunity. The suggested change in the bug report gets halfway there but I think there's also an unrelated bug where we'd start to condense a tool loop, continue the conversation, then get Anthropic yelling at us again because we condensed the thinking block and it still wants to keep the tool loop going. My hypothesis is that what Claude Code does is more likely to get the agent off-track than our rolling condensations. We would probably be well-served by making the condensation parameters a little less aggressive though. I'm traveling the next two days so I'll only be sporadically available, but back at on Wednesday if you want to assign me the issue to look at then. In the meantime maybe we can just set
keep_first=2
(or it might be
1
, can't remember the indexing atm) and
max_size=180
or
240
or something else large.
👍 1
a
strong +1 to at least considering CC’s approach and seeing where we can improve in the most recent updates of CC with opus 4.5 I was extremely impressed by the detail of its condensation messages, to the point where I’ve started saving a few condensation messages to study from and try and suggest improvements to our approach at some point in the future
w
@adamant-controller-19704 would love to hear any suggestions you might have! Just want to clarify any apparent resistance I have to CC's approach isn't so much the "what/how" as the "when", but if we need to modify that too then all good. We just need to be careful about pushing condensation back too far as that has an impact on the cost of long-running conversations and we don't have Anthropic's usage/subscription model to hide token costs.
🙏 1
l
(I would say that when I’ve used CC I’ve had a less good experience after compaction than with OpenHands condensation, but I’m happy to try new things)
🙏 1
a
@wide-doctor-37830 that makes total sense!
to be honest I've had bad (and good) experiences with both OH compaction and CC’s compaction lol… at the end of the day to me the more interesting question is: is CC doing anything we can learn or steal from that would help us greatly? in that regard, specifically with the most recent CC compaction summaries I've seen, the summary details are very good and I imagine there’s something there we can consider
i spent my free time this break building a OpenHands hooks system for the SDK so next time I get some free time I'll organize my condensation notes and share them out for discussion
🙌 2
l
Yeah, thanks a lot Alona, any insights are super-helpful!
a
of course! thanks yall!
c
On this note, I saw practically only good experience with codex-cli's approach. One thing I noticed is that the LLM is told to make sure that the state of the repo is what it thinks it is - so the first thing it does is look at branch/diff and maybe more, to get tabs on the current situation again. I guess we may need less of this if it has ~half, though occasionally it may prevent the strange cases when it feels like OH is restarting (they seem rare these days though)
c
👆 yeah, and on the plus side, the approach of condense + starting everything from scratch could help avoid some of the edge cases we were trying to fix lately (e.g., mixture of thinking blocks, wrong order of action-observation event pairs). But it is definitely a relatively bigger effort
nod 2
l
I agree, but I think starting everything from scratch has a fairly high likelihood of confusing the agent. It’d be nice if we still keep the option to not do that
One other thing we could do is fall back to that strategy if we get a malformed message error thinky spin
nod 1
c
yeah i think fallback is definitely reasonable
starting everything from scratch has a fairly high likelihood of confusing the agent
especially in cases where we use open-source models nod
l
@nutritious-balloon-65098 Create an issue on the software-agent-sdk repo based on this discussion that when we encounter a malformed message error from the language model, we should fall back to condensing the entire trajectory into a single message, similarly to how Claude Code does it. Assign this to
csmith49
n
I'm on it! Graham Neubig can track my progress here.
I've successfully created the issue on the software-agent-sdk repository based on the discussion. Issue Created: https://github.com/OpenHands/software-agent-sdk/issues/1529 Title: Fallback to full trajectory condensation on malformed message errors Summary of the issue: • When a malformed message error is encountered from the language model, the system should fall back to condensing the entire trajectory into a single message (similar to Claude Code's approach) • This is proposed as a fallback strategy, not the default behavior • The existing condensation approach remains the primary method, with this as a safety net for error cases • This could help avoid edge cases like mixture of thinking blocks and wrong order of action-observation event pairs Assigned to: csmith49 No code changes were made - this was purely an issue creation task. <sub>View full conversation</sub>