Skip to content
providerkit
GitHub

OperationReceipt

type OperationReceipt =
| RemoteReceipt
| {
attemptId: string;
billing: "unknown" | "reported";
costUsd?: number;
id: string;
kind: "model";
purpose?: "compaction";
source?: Turn["source"];
status: "running" | "completed" | "interrupted" | "context_rejected";
usage: TokenUsage;
}
| {
attemptId: string;
callId: string;
costUsd?: number;
id: string;
kind: "tool" | "delegation" | "handoff";
parentOperationId?: string;
result?: ToolResult;
status: "running" | "completed" | "interrupted" | "asked";
};

Defined in: agents/src/types.ts:1076

Stable operation identity; an attempt changes on resume, an operation does not. A model receipt’s usage may be partial if the stream failed.

RemoteReceipt


{
attemptId: string;
billing: "unknown" | "reported";
costUsd?: number;
id: string;
kind: "model";
purpose?: "compaction";
source?: Turn["source"];
status: "running" | "completed" | "interrupted" | "context_rejected";
usage: TokenUsage;
}
attemptId: string;
billing: "unknown" | "reported";

reported means a stream with usage ended, not that the SDK verified the vendor’s bill.

optional costUsd?: number;

The host’s price for this usage, saved when it arrived.

id: string;
kind: "model";
optional purpose?: "compaction";
optional source?: Turn["source"];
status: "running" | "completed" | "interrupted" | "context_rejected";
usage: TokenUsage;

{
attemptId: string;
callId: string;
costUsd?: number;
id: string;
kind: "tool" | "delegation" | "handoff";
parentOperationId?: string;
result?: ToolResult;
status: "running" | "completed" | "interrupted" | "asked";
}
attemptId: string;
callId: string;
optional costUsd?: number;

What this attempt reported through context.reportCost.

id: string;
kind: "tool" | "delegation" | "handoff";
optional parentOperationId?: string;
optional result?: ToolResult;
status: "running" | "completed" | "interrupted" | "asked";

asked: the attempt reported a cost, then stopped to ask the person. The answer runs the tool again as a new attempt with its own receipt, so the charge stays on this one. An attempt that asked without reporting a cost gets no receipt.