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:
@@ -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 }),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user