Quando è emitata
Solo su run({ edit: n, message }) — editare un messaggio anterior significa tornare a lui e ricominciare con un nuovo testo. L'evento è emanato prima di ningun altro del run.
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,
)Campos
{
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},
}nintegerIl messaggio ritornò a.
removedobjectQuants messaggi e assistente gira a sinistra la conversa.
filesobject- e skipped, con una ragione per cada.
keptarrayQuanto ha lasciato la máquina e sta a posto — un send, un deploy, un write de storage, un workflow, un comando.
creditsobject{ spent, refunded: 0 }. Le virajes remose sono fatturate, e non sono restituite.
manteve il campo da mostrar
Se tenuta non è vazio, qualcosa accadì che ritornante non inversa. Una interface che nasconde dice l'usuario la run era cancela, che è falso — e falso nella direzion che importa.
Un rebobinat puè fail
Lance antes di emettere qualquer cosa: session_required, agent_running, checkpoints_disabled, checkpoint_compacted, checkpoint_not_found, invalid_checkpoint. La run non inizia.
Rewinding senza correre
const outcome = await agent.rewind(2); // the same object, returned rather than emittedoutcome = agent.rewind(2) # the same object, returned rather than emitted