feat(agent): 云端 Agent - 增加上下文预算、任务事实与终态恢复保障

This commit is contained in:
ddCat committed 2026-09-19 20:43:20 +08:00
1 parent 3bf21d79af
commit b52bc9d5f2
61 files changed
+3512 -309

No files matched your search

@@ -310,6 +310,11 @@ func (r *Repository) SwitchTaskLogicalRoute(taskID string, expectedRouteID strin
if replacement.UserID != order.UserID || replacement.TaskID != taskID || replacement.AmountMicrocredits <= 0 {
return ErrBillingStateConflict
}
// The new supplier price cannot expand the user's original authorization.
// Keep the existing cap; replacement is a price snapshot, not a new grant.
if err := validateBillingChargeLimit(order, replacement.AmountMicrocredits); err != nil {
return err
}
reserved := order.ReservedAmountMicrocredits
if reserved <= 0 {
reserved = order.AmountMicrocredits