MCPcopy
hub / github.com/docker/docker-agent / CompactSession

Method CompactSession

pkg/app/app.go:1105–1137  ·  view source on GitHub ↗
(ctx context.Context, cancel context.CancelFunc, additionalPrompt string)

Source from the content-addressed store, hash-verified

1103}
1104
1105func (a *App) CompactSession(ctx context.Context, cancel context.CancelFunc, additionalPrompt string) {
1106 a.cancel = cancel
1107
1108 sess := a.session
1109 if sess == nil {
1110 cancel()
1111 return
1112 }
1113
1114 go func() {
1115 defer cancel()
1116
1117 agentName := a.runtime.CurrentAgentName(ctx)
1118 completed := false
1119 events := make(chan runtime.Event, 100)
1120 go func() {
1121 defer close(events)
1122 a.runtime.Summarize(ctx, sess, additionalPrompt, runtime.NewChannelSink(events))
1123 }()
1124 for event := range events {
1125 if ctx.Err() != nil {
1126 return
1127 }
1128 if e, ok := event.(*runtime.SessionCompactionEvent); ok && e.Status == "completed" {
1129 completed = true
1130 }
1131 a.sendEvent(ctx, event)
1132 }
1133 if !completed && ctx.Err() == nil {
1134 a.sendEvent(ctx, runtime.SessionCompaction(sess.ID, "completed", agentName))
1135 }
1136 }()
1137}
1138
1139func (a *App) PlainTextTranscript() string {
1140 return transcript.PlainText(a.session)

Callers

nothing calls this directly

Calls 6

sendEventMethod · 0.95
NewChannelSinkFunction · 0.92
SessionCompactionFunction · 0.92
CurrentAgentNameMethod · 0.65
SummarizeMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected