feat(cloud-agent): 上下文计量 - 每步发出 context_pressure 读数并用上游实测定锚 (#601)

This commit is contained in:
AetherNo2332
2026-09-24 13:35:15 +08:00
committed by ddcat666
parent 7ca625730e
commit abf593c6c9
12 changed files with 1366 additions and 15 deletions

View File

@@ -108,6 +108,26 @@ func (s *Service) attachCloudAgentLessons(canonical *canonicalAgentRequest, user
}
}
// cloudAgentRecordMemorySegment 把系统提示里已经存在的个人记忆块登记为分段。
// 记忆块是在策略编译之后拼接的,编译器录不到它;不登记就会让"系统提示分段"合计
// 小于 system 桶,读数看起来像少算了一截。
func cloudAgentRecordMemorySegment(policy *cloudAgentPolicySnapshot, system string) {
if policy == nil {
return
}
index := strings.Index(system, cloudAgentLessonBlockMarker)
if index < 0 {
for i := range policy.SystemSegments {
if policy.SystemSegments[i].Key == "memory" {
policy.SystemSegments = append(policy.SystemSegments[:i], policy.SystemSegments[i+1:]...)
break
}
}
return
}
cloudAgentRecordSystemSegment(policy, "memory", "个人记忆", system[index:])
}
func cloudAgentRememberLesson(repo *repository.Repository, userID string, state *cloudAgentRuntime, call cloudAgentCall) (any, error) {
if state == nil {
return nil, BadAuthRequest("当前运行状态无效")