Goose stops responding without any error message once conversation hits context limit on openrouter.
Describe the bug Goose will eventually just stop responding and not display the error message from the llm, in this case, openrouter using anthropic/claud-3.5-sonnet
To Reproduce Steps to reproduce the behavior:
- Build for long enough to exceed 200K context.
Expected behavior Expected behavior is that Goose would use the middle out transform and compress prompt to context limit or just below it so it doesn't fail.
Screenshots
Trace from langfuse:
This endpoint's maximum context length is 200000 tokens. However, you requested about 201326 tokens (197771 of text input, 3555 of tool input). Please reduce the length of either one, or use the "middle-out" transform to compress your prompt automatically.
Please provide following information:
- OS & Arch: [Ubuntu 24.04 x86]
- Interface: [CLI]
- Version: [v1.0.7]
- Extensions enabled: [Developer,Computer Controller, Memory,Fetch,Git,Github]
- Provider & Model: [openrouter:anthropic/claude-3.5-sonnet]
Additional context Add any other context about the problem here.
@myevolve thanks for reporting it, previously we have some discussion about the truncate on goose for all providers, will update here later
This has been ongoing and since 1.0.1 at least. I've reported it many times. Be nice to fix this once and for all, because the console (CLI and GUI) failure is not at all descriptive of the issue.
@HunterR0se I believe this specific error is coming from OpenRouter - https://openrouter.ai/docs/features/message-transforms
However, in the case that OpenRouter doesn't handle context length errors, Goose should try to do a better job at truncating.
Bump. This is the biggest issue I'm having recently. It requires restarting a new goose session, and then having to get goose up to speed all over again.
Bump. This is the biggest issue I'm having recently. It requires restarting a new goose session, and then having to get goose up to speed all over again.
Exactly! And the amount of tokens and API calls to do this is both mentally (and financially) burdensome at the least and infuriating at most.
I love goose, but this really is a "show stopper" issue for the project.
I've been working on an initial fix for this since it's a critical bug. Put up what I have so far: https://github.com/block/goose/pull/3635
Looking for testers, feedback, and/or contributions. Thanks!
@michaelneale is this still the case? seems like we should make sure this works before we make openrouter a default if not
I can confirm this still happens today, @DOsinga I use OpenRouter's Qwen3 Coder
thanks @igorgue we will priotitize this then :-(
@kwsantiago do you see your fix helping with openrouter?
aside: I expect this is less of an issue with the new auto compact (ie just few days ago), but good to have it not just halt!
@michaelneale it should, and middle-out support could also help.
However I don't have paid access to OpenRouter API, so ideally someone could test with it on the fix branch.
I am trying out the middle-out stuff in OR as well, as it won't hurt I believe, so between all the above, we should be in a good place soon.
ok middle-out seems to be great, easy too, so I think we can close this once that lands in https://github.com/block/goose/pull/3881
closing this as that PR fixes that (along with other changes on main which are just coming out) - can re-open it if we need to revisit this, thanks everyone for all the angles and ideas.