MCPcopy Create free account
hub / github.com/betta-tech/byo-coding-agent / cmdCompact

Function cmdCompact

commands.go:264–291  ·  view source on GitHub ↗
(args string)

Source from the content-addressed store, hash-verified

262}
263
264func cmdCompact(args string) {
265 strategy := rootAgent.Compactor
266 switch strings.ToLower(args) {
267 case "":
268 // use the configured compactor
269 case "sliding":
270 strategy = &compact.SlidingWindow{KeepLast: 6}
271 case "summarize":
272 strategy = &compact.Summarize{Provider: rootAgent.Provider, Threshold: 0, KeepRecent: 4}
273 case "none":
274 strategy = compact.NoCompaction{}
275 default:
276 fmt.Printf("unknown strategy: %s (try sliding, summarize, or none)\n", args)
277 return
278 }
279
280 before := rootAgent.Messages()
281 compacted, err := strategy.Compact(context.Background(), before)
282 if err != nil {
283 fmt.Printf("compaction error: %v\n", err)
284 return
285 }
286 rootAgent.SetMessages(compacted)
287 fmt.Println(ui.Dimmed(fmt.Sprintf("compacted: %d → %d messages", len(before), len(compacted))))
288 if rootAgent.Verbose && len(before) != len(compacted) {
289 ui.PrintCompaction(before, compacted)
290 }
291}
292
293func cmdVerbose(args string) {
294 switch strings.ToLower(args) {

Callers

nothing calls this directly

Calls 5

DimmedFunction · 0.92
PrintCompactionFunction · 0.92
MessagesMethod · 0.80
SetMessagesMethod · 0.80
CompactMethod · 0.65

Tested by

no test coverage detected