Skip to content

Proposal: Stream Tool Arguments #82

@MiguelsPizza

Description

@MiguelsPizza

Currently, execute fires after the full args JSON is parsed. For tools with large text args (email bodies, code), it'd be nice to stream chunks into page UI as the model generates them. example from userland

navigator.modelContext.registerTool({
  name: "compose_email",
  stream: true,
  inputSchema: { /* to, subject, body */ },
  execute: async (call) => {
    composer.open();
    for await (const { key, chunk } of call) {
      if (key === "to")   composer.appendTo(chunk);
      if (key === "body") composer.appendBody(chunk);
    }
    const { to, subject, body } = await call.args;
    return { content: [{ type: "text", text: `Draft created` }] };
  }
});

For declarative tools this could be default behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions