add usage info to branch summary, compaction and tool result entries (#6671)

* add usage info to branch summary entries

* add usage to compaction entries

* allow custom tools to report llm usage in tool results

* allow observing and patching usage in tool_result hooks

* agent-harness: save usage in entries

for compaction, branch summaries and tool results
This commit is contained in:
David Brailovsky
2026-07-20 16:41:43 +02:00
committed by GitHub
parent c179395218
commit 2fd3868401
29 changed files with 844 additions and 122 deletions
+8
View File
@@ -1,3 +1,4 @@
import type { Usage } from "@earendil-works/pi-ai";
import { type Static, Type } from "typebox";
import type { AgentTool, AgentToolResult } from "../../src/types.ts";
@@ -30,3 +31,10 @@ export const calculateTool: AgentTool<typeof calculateSchema, undefined> = {
return calculate(args.expression);
},
};
export function createCalculateToolWithUsage(usage: Usage): AgentTool<typeof calculateSchema, undefined> {
return {
...calculateTool,
execute: async (_toolCallId: string, args: CalculateParams) => ({ ...calculate(args.expression), usage }),
};
}