fix(agent): 修复上下文压缩检查点保存失败

This commit is contained in:
ddcat666
2026-09-27 18:31:24 +08:00
parent 258422757c
commit 367145010f
4 changed files with 189 additions and 16 deletions

View File

@@ -68,7 +68,7 @@ func cloudAgentCompactionReadingFor(budget cloudAgentContextBudget, projectedTok
if budget.InputBudgetTokens > 0 {
reading.PressureRatio = math.Round(float64(projectedTokens)/float64(budget.InputBudgetTokens)*10000) / 10000
}
if budget.Source == "" || budget.Source == "default" {
if !budget.Configured || budget.Source == "" || budget.Source == "default" {
return reading, false
}
return reading, true
@@ -470,7 +470,7 @@ func (s *Service) writeCloudAgentContextCheckpoint(run *model.CloudAgentExecutio
recent := cloudAgentCompleteTurnTail(state.Canonical.Messages, cloudAgentContextKeepPairs)
history, err := cloudAgentCheckpointHistory(checkpoint, recent)
if err != nil {
return fmt.Errorf("%w: %v", errCloudAgentCheckpoint, err)
return cloudAgentCheckpointFailure("compaction checkpoint history", err)
}
return s.repo.MutateCloudAgent(run.UserID, run.ID, run.Revision, func(current *model.CloudAgentExecution, _ *repository.Repository) error {
state.ContextCheckpoint = &checkpoint