Skip to content

registerTool should return registered tool instead of undefined #234

Description

@beaufortfrancois

When registering and executing tools, I often see boilerplate code that requires an extra call to getTools().

await document.modelContext.registerTool({
  name: "tool",
  description: "A tool",
  execute: () => {},
});

const [tool] = await document.modelContext.getTools();
await document.modelContext.executeTool(tool, "{}");

Could we simplify this workflow by having registerTool() return the registered tool object directly? That way, we can pass it straight into executeTool() without the extra lookup step (which is not required by the way).

const tool = await document.modelContext.registerTool({
  name: "tool",
  description: "A tool",
  execute: () => {},
});

await document.modelContext.executeTool(tool, "{}");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions