Eventos

tool_start

{ type: "tool_start", id, tool, category, args }

Un utensiliu è pet per runt, con i argumenti con il que va runt. Arriva dopo che un permese è stato concessa — donc tching it significa che la chiamata sta avvenendo.

after the permissionargs are finalpaired with tool_end
Using Python?

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

Campos

idstring

Identificator del call. tool_end porta il medesimo.

toolstring

Nome del utense.

categorystring

Sue categoria — calcolat a partir dei argumenti per sei di essi.

argsobject

Exactamente con cui va correr.

Aparejando

const started = new Map();

onEvent: (e) => {
  if (e.type === "tool_start") started.set(e.id, { tool: e.tool, at: Date.now(), args: e.args });
  if (e.type === "tool_end")   {
    const call = started.get(e.id);
    console.log(call.tool, e.ok ? "ok" : "failed", e.durationMs, "ms");
    started.delete(e.id);
  }
};
import time

started = {}

def on_event(event):
    if event["type"] == "tool_start":
        started[event["id"]] = {"tool": event["tool"], "at": time.monotonic(), "args": event["args"]}
    if event["type"] == "tool_end":
        call = started.pop(event["id"])
        print(call["tool"], "ok" if event["ok"] else "failed", round((time.monotonic() - call["at"]) * 1000), "ms")
Non ogni tool_end ha un tool_start

Un appello rifiutat e un appello a un utensilio sconosciut emitono solo tool_end. Pari per id e tolere un fine senza comince, o un entrie penzuria se sedue in tuo map per sempre.

Diversi puère essere apertos d'una volta

In un turn in cui ogni chiamata è un read o un task, il motor le rulera insieme — così si può vedere varios tool_start prima del primo tool_end, e le fines arrivano in ordine di completamento, non chiama ordine. Keying on id è lo che rende innocuo.

I argumenti sono la display

args.path, args.command, args.query, args.pattern, args.key — a única string significante é o que mostra una interface junto al nome del instrumento. O recorde de session mantiene la stessa idea que un corto target.

Os eventos dos subagentes também chegam aqui

Porten id parent — l'identificant del tòc iss is inizion — e agente, il nome. Il loro id propri è prefissat con il tòc is, donc due runs mai collidere. Test parentId prima de tratât un evento come il run principal.