src / agents / tools / notes.ts
import { tool, type Tool } from "@lmstudio/sdk";
import { z } from "zod";
import { okResult } from "../../core/result";
import { unique, type AgentToolContext } from "./context";
/** `record_note` — a durable note future passes must retain. */
export function createRecordNoteTool(ctx: AgentToolContext): Tool {
const { state, beforeTool } = ctx;
return tool({
name: "record_note",
description:
"Persist a concise decision, constraint, blocker, or fact that future passes must retain.",
parameters: { note: z.string() },
implementation: async (input: { note: string }) => {
await beforeTool("record_note");
state.notes = unique([...state.notes, input.note.slice(0, 1000)]).slice(-30);
await ctx.store.event(state, {
type: "note",
summary: input.note.slice(0, 1000),
});
return okResult({
operation: "agent.note",
summary: "Durable note recorded.",
facts: [input.note.slice(0, 1000)],
});
},
});
}
src / agents / tools / notes.ts
import { tool, type Tool } from "@lmstudio/sdk";
import { z } from "zod";
import { okResult } from "../../core/result";
import { unique, type AgentToolContext } from "./context";
/** `record_note` — a durable note future passes must retain. */
export function createRecordNoteTool(ctx: AgentToolContext): Tool {
const { state, beforeTool } = ctx;
return tool({
name: "record_note",
description:
"Persist a concise decision, constraint, blocker, or fact that future passes must retain.",
parameters: { note: z.string() },
implementation: async (input: { note: string }) => {
await beforeTool("record_note");
state.notes = unique([...state.notes, input.note.slice(0, 1000)]).slice(-30);
await ctx.store.event(state, {
type: "note",
summary: input.note.slice(0, 1000),
});
return okResult({
operation: "agent.note",
summary: "Durable note recorded.",
facts: [input.note.slice(0, 1000)],
});
},
});
}