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

Method summarize

sessionmemory/store.go:407–436  ·  view source on GitHub ↗
(ctx context.Context, startTurn, endTurn int, previews []string)

Source from the content-addressed store, hash-verified

405 if payload.UserTurn > 0 {
406 userTurn = payload.UserTurn
407 } else if taggedTurn := sessionUserTurn(msg); taggedTurn > 0 {
408 userTurn = taggedTurn
409 } else if isRealUserRequest(msg) {
410 userTurn++
411 }
412 if userTurn == 0 {
413 continue
414 }
415 role := stringValue(msg["role"])
416 contentJSON, err := json.Marshal(msg["content"])
417 if err != nil {
418 return err
419 }
420 hash := messageHash(userTurn, role, contentJSON)
421 preview := textPreview(msg, 1200)
422 now := unixNow()
423 if _, err := tx.ExecContext(ctx, `INSERT OR IGNORE INTO messages(
424 turn_count, user_turn_count, role, content_json, text_preview, message_hash, source_event_id, created_at, last_accessed_at
425 ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)`, userTurn, userTurn, role, string(contentJSON), preview, hash, event.ID, now, now); err != nil {
426 return err
427 }
428 }
429 return tx.Commit()
430}
431
432func (s *Store) MaybeCommit(ctx context.Context, force bool) error {
433 interval := s.cfg.SessionMemoryTurnInterval
434 if interval <= 0 {
435 interval = 5
436 }
437 lastCommitted := s.metaInt(ctx, "last_committed_user_turn")
438 maxUserTurn := s.maxUserTurn(ctx)
439 if maxUserTurn <= lastCommitted {

Callers 1

CommitRangeMethod · 0.95

Calls 7

summaryModelMethod · 0.95
CreateLLMClientFunction · 0.92
DefaultRetryConfigPtrFunction · 0.92
parseSummaryResponseFunction · 0.85
firstLineFunction · 0.85
clampFunction · 0.85
CompleteMethod · 0.65

Tested by

no test coverage detected