Eventos

rewined

{ type: "rewound", n, removed, files, kept, credits }

Una run che era chiesto per editare un messaggio anterior è tornat prima. Porta esattamente lo que rewind() restituisce — incluso quello che retorn non ha desfare.

only with run({ edit })before anything elsenames what stays done
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

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},
}
ninteger

Il messaggio ritornò a.

removedobject

Quants messaggi e assistente gira a sinistra la conversa.

filesobject

- e skipped, con una ragione per cada.

keptarray

Quanto 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

« Rewound » describe i files, non il mondo

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 emitted
outcome = agent.rewind(2)   # the same object, returned rather than emitted