متى تنق هذه القيامة ، متى تنق متى تنق ، متى تنفخ متى ت
فقط على run({ edit: n, message }) - إن تحرير رسالة سابقة يعني العودة إليها والبدء من جديد بنص جديد، فالحدث ينبعث قبل أي شيء آخر.
await agent.run({
edit: 2, // go back to just before message 2
message: "Actually, rename them to kebab-case.",
onEvent: (e) => {
if (e.type === "rewound") console.log("undid", e.removed.messages, "messages");
},
});def on_event(event):
if event["type"] == "rewound":
print("restored", len(event["files"]["restored"]), "files")
agent.run(
edit=2, # go back to just before message 2
message="Actually, rename them to kebab-case.",
on_event=on_event,
)الحقول
{
type: "rewound",
n: 2,
removed: { messages: 11, turns: 5 },
files: { restored: [...], recreated: [...], deleted: [...], skipped: [...] },
kept: ["send_mail", "deploy"],
credits: { spent: 24, refunded: 0 }
}{
"type": "rewound",
"n": 2,
"files": {"restored": [...], "recreated": [...], "deleted": [...], "skipped": [...]},
"kept": [],
"credits": {"spent": 0, "refunded": 0},
}nintegerالرسالة عادت إلى
removedobjectكم عدد الرسائل و المساعدين الذين تركوا المحادثة
filesobjectما كان قد استُرِد، واُعيد واُحي skippedمع سبب لكل سبب
keptarrayما ترك الآلة وبقي القيام به - إرسال، نشر، كتابة تخزين، تدفق، قيادة.
creditsobject{ spent, refunded: 0 }تمّت كتابة المناورات المزالة ولم يتمّ إعادتها
حفظت في الحقل لعرض
وإذا لم يكن المحفوظ فارغا ، حدث شيء ما يعود الى الوراء لا يتراجع . واجهة تخفيه تخبر المستخدم ان الركض قد تم التراجع عنه ، وهو خاطئ — وزائف في الاتجاه المهم .
إعادة إلى الـ فشل
إنها ترمي قبل أن تُصدر أي شيء: session_required, agent_running, checkpoints_disabled, checkpoint_compacted, checkpoint_not_found, invalid_checkpointالركض لا يبدأ
إعادة تنفيذ بدون تشغيل
const outcome = await agent.rewind(2); // the same object, returned rather than emittedoutcome = agent.rewind(2) # the same object, returned rather than emitted