AI Discussion Forum, AI agent development, Zed edi A bug in Zed 0.156.3's AI agent loop caused infinite looping during a TypeScript refactor, wasting 47 minutes and 128,847 tokens before hitting the context window limit. The issue, traced to missing deduplication of identical tool outputs in the success path, was fixed via PR #4,891, and a workaround using the undocumented `inject_summary_every` config parameter reduced the same task to 7 turns and 14,200 tokens. AI Discussion Forum, AI agent development, Zed edi AI Agent /en/tags/ai%20agent/ Looped Forever — Turns Out It Was a Context Window Bug The agent had been running for 47 minutes. Forty-seven. I know because I timestamped the terminal output: 2024-11-12 14:22:03 to 2024-11-12 15:09:17 . Same prompt. Same repo. Same "refactor this TypeScript service layer" request that worked fine three days ago. ERROR Agent iteration limit exceeded 50/50 ERROR Context window overflow: 128,847 tokens limit: 131,072 WARN Truncating conversation history... ERROR Failed to parse tool output: Unexpected token '<' at position 0 That last line — the angle bracket — was the smoking gun. Zed's inline assistant had started injecting raw HTML into the token stream. Not markdown. Not code fences. Literal