MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / ExecuteAutoCompactWithRetry

Function ExecuteAutoCompactWithRetry

agentContext/auto.go:316–334  ·  view source on GitHub ↗
(ctx context.Context, messages []map[string]any, systemPrompt string, llmClientFunc LLMClientFunc)

Source from the content-addressed store, hash-verified

314}
315
316func ExecuteAutoCompactWithRetry(ctx context.Context, messages []map[string]any, systemPrompt string, llmClientFunc LLMClientFunc) (string, error) {
317 currentMessages := deepcopy.Copy(messages).([]map[string]any)
318 for attempt := 0; attempt <= MaxPtlRetries; attempt++ {
319 summary, err := llmClientFunc(ctx, currentMessages, systemPrompt)
320 if err == nil {
321 return summary, nil
322 }
323 if !isPtlError(err) {
324 return "", err
325 }
326 if attempt >= MaxPtlRetries {
327 slog.Warn(fmt.Sprintf("PTL retry exhausted (%d attempts), giving up.", attempt+1))
328 return "", errors.New("PTL retry exhausted")
329 }
330 slog.Warn(fmt.Sprintf("PTL error on auto compact attempt %d/%d: %s", attempt+1, MaxPtlRetries+1, err.Error()))
331 currentMessages = TruncateHeadForPtlRetry(ctx, currentMessages)
332 }
333 return "", errors.New("unreachable")
334}
335
336func RunPostCompactCleanUp(ctx context.Context, state any, recentReadFiles []map[string]string) {
337 if recentReadFiles == nil {

Calls 3

isPtlErrorFunction · 0.85
TruncateHeadForPtlRetryFunction · 0.85
ErrorMethod · 0.45