Skip to content

The open source coding agent.

TypeScript

fix agent getting caught in summary loop

Dax Raad57b3051024bb
diff --git a/opencode.json b/opencode.json
index e20209c660c..a7d952b777e 100644
--- a/opencode.json
+++ b/opencode.json
@@ -1,5 +1,13 @@
{
"$schema": "https://opencode.ai/config.json",
"mcp": {},
- "provider": {}
+ "provider": {
+ "openrouter": {
+ "npm": "@openrouter/ai-sdk-provider",
+ "name": "OpenRouter",
+ "models": {
+ "anthropic/claude-sonnet-4": {}
+ }
+ }
+ }
}
diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts
index 8baf7da0fb6..0dd4e4e626c 100644
--- a/packages/opencode/src/session/index.ts
+++ b/packages/opencode/src/session/index.ts
@@ -210,8 +210,9 @@ export namespace Session {
previous.metadata.assistant.tokens.cache.write +
previous.metadata.assistant.tokens.output
if (
+ model.info.limit.context &&
tokens >
- (model.info.limit.context - (model.info.limit.output ?? 0)) * 0.9
+ (model.info.limit.context - (model.info.limit.output ?? 0)) * 0.9
) {
await summarize({
sessionID: input.sessionID,