事件

转转

{ type: "turn", model, durationMs, inputTokens, cachedTokens, contextTokens, contextLimit, contextParts, contextCleared, credits, totalCredits }

每一个步骤,在模型回答后。它包含步骤成本、环境的全度以及哪个模式实际上为它服务。

one per stepmeasured, not estimatedtotalCredits is the run
Using Python?

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

字段

modelstring

哪个模式 下 个 并非总是你要求的 后退 每一转弯都会改变它。

durationMsinteger

转弯要多久

inputTokensinteger|null

供应商在进入时所指望的是什么。

cachedTokensinteger

提供商从储藏处得到了多少服务

contextTokensinteger

对话框的大小与所测量的对话框大小相同。 inputTokens 有空时。

contextLimitinteger

有效限度——你的 contextTokens,或违约。

contextPartsobject

{ system, tools, memory, messages },因此它们加起来等于总数。

contextClearedinteger

到目前为止,这次清理工作已经清空了多少工具结果。

creditsinteger

转弯要花多少钱?

totalCreditsinteger

至今为止,运行的代价是多少? 将工具一起转转,然后将工具一起转.

上下文测量

onEvent: (e) => {
  if (e.type !== "turn") return;
  const pct = Math.round((e.contextTokens / e.contextLimit) * 100);
  console.log(`${pct}% of the window · ${e.cachedTokens} cached · ${e.contextCleared} results cleared`);
  console.log(e.contextParts);   // { system: 2100, tools: 3900, memory: 180, messages: 25024 }
};
# Python has no "turn" event: read agent.context and agent.usage whenever a tool finishes
def on_event(event):
    if event["type"] != "tool_end":
        return
    context = agent.context
    pct = round(context["tokens"] / context["limit"] * 100)
    print(f"{pct}% of the window · {context['cleared']} results cleared")
    print(context["parts"])   # {"system": 2100, "tools": 3900, "memory": 0, "messages": 25024}
计算总总和;四部分是估计和按比例缩放的

提供商给出了总数。 部件根据其大小估算, 然后缩放, 四个组合完全相加—— 比例合理, 单个部分接近而不是精确。

已经计算工具的 credits 已经计算

不添加工具 meta.credits 在上面的顶上

当工具完成时, 支付的工具的成本会添加到运行总量中, 因此下一转事件已经包含它。 添加两者后算出两次。 账户工具所读的余额是平衡, 不是成本 — 把它当做运行看起来非常昂贵。

哪个模型在其中

字段是转弯的模型。 观察它就是静态降解如何变得可见: 以一个模型开始、 后退结束的运行 已经是不好的时机, 即使每个答案都很好 。

值得显示的名

长期对话的前缀稳定,主要来自缓存,缓存输入的账单比正常费率少了一小部分。 两个转弯之间跌至零的数字意味着快感变化的开始时间,即新工具、新存储、已清理的批次。

子智能体事件也会传递到这里

它们随身携带 palclId —— 启动它们的任务电话的识别符号 —— 以及代理、 其名称。 他们自己的代号与任务名称相加, 所以两个运行时不会相撞 。 在将事件作为主运行程序处理之前先测试 palId 。