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

Method BuildRecoveryAttachment

skills/persistence.go:79–119  ·  view source on GitHub ↗
(agentScope string)

Source from the content-addressed store, hash-verified

77}
78
79func (p *SkillPersistence) BuildRecoveryAttachment(agentScope string) *string {
80 if p == nil {
81 return nil
82 }
83 if agentScope == "" {
84 agentScope = "main"
85 }
86 p.mu.Lock()
87 scopeRecords := p.records[agentScope]
88 records := make([]InvokedSkillRecord, 0, len(scopeRecords))
89 for _, name := range p.order[agentScope] {
90 if record, ok := scopeRecords[name]; ok {
91 records = append(records, record)
92 }
93 }
94 if len(records) < len(scopeRecords) {
95 for name, record := range scopeRecords {
96 if !stringInSlice(name, p.order[agentScope]) {
97 records = append(records, record)
98 }
99 }
100 }
101 p.mu.Unlock()
102 if len(records) == 0 {
103 return nil
104 }
105
106 totalCharsBudget := PostCompactSkillsTokenBudget * CharsPerTokenEstimate
107 maxCharsPerSkill := PostCompactMaxTokensPerSkill * CharsPerTokenEstimate
108 candidates := buildRecoveryCandidates(records, maxCharsPerSkill)
109 selected := selectRecoveryRecords(candidates, totalCharsBudget)
110 if len(selected) == 0 {
111 return nil
112 }
113 parts := make([]string, 0, len(selected))
114 for _, candidate := range selected {
115 parts = append(parts, candidate.section)
116 }
117 text := recoveryHeader + strings.Join(parts, recoverySectionSeparator) + recoveryFooter
118 return &text
119}
120
121func (p *SkillPersistence) BuildRecoveryMessage(agentScope string) map[string]any {
122 text := p.BuildRecoveryAttachment(agentScope)

Calls 3

stringInSliceFunction · 0.85
buildRecoveryCandidatesFunction · 0.85
selectRecoveryRecordsFunction · 0.85