open-code-review/internal/agent
kite 2f3ed41009 refactor(agent): split agent.go into util.go and compression.go, fix compression bugs
Extract utility functions (stripEmptyPlanBlock, stripMarkdownFences,
buildMessageXML, copyMessages, countMessagesTokens, reviewModeString,
detectGitBranch) into util.go and all compression logic into compression.go
to improve readability (agent.go: 1489 → 1114 lines).

Fix pre-existing compression bugs from commit 14adf6f:
- Return unmodified messages on compression failure instead of truncating
  to frozen zone (which discarded all conversation context)
- Check error in async compression goroutine to avoid applying failed results
- Track snapshot length to append post-snapshot messages when applying async
  compression, preventing silent message loss
- Strip old <previous_review_summary> before appending new one to prevent
  cumulative frozen zone bloat across multiple compressions
- Guard pendingJob cleanup to only clear when it matches the completed job,
  preventing accidental clearing of a newly scheduled job
- Add context.Context and 5s timeout to detectGitBranch
- Deep copy ToolCalls in copyMessages to match session/history.go
- Reuse finalCount in addNextMessage to avoid redundant token counting
2026-06-21 21:20:40 +08:00
..
agent.go refactor(agent): split agent.go into util.go and compression.go, fix compression bugs 2026-06-21 21:20:40 +08:00
compression.go refactor(agent): split agent.go into util.go and compression.go, fix compression bugs 2026-06-21 21:20:40 +08:00
preview.go fix(diff): detect renamed and deleted files correctly in diff parsing (#105) 2026-06-14 22:29:02 +08:00
preview_test.go fix(agent): user includes should have higher priority than system supported extensions (#51) 2026-06-12 14:29:47 +08:00
util.go refactor(agent): split agent.go into util.go and compression.go, fix compression bugs 2026-06-21 21:20:40 +08:00
util_test.go refactor(agent): split agent.go into util.go and compression.go, fix compression bugs 2026-06-21 21:20:40 +08:00