-
Notifications
You must be signed in to change notification settings - Fork 11
Show meaningful tool loading labels in chat UI #500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||
| import { tool, zodSchema } from "ai"; | ||||||
| import { z } from "zod"; | ||||||
| import { loadStateForTool } from "./tool-utils"; | ||||||
| import { loadStateForTool, toolTitleField } from "./tool-utils"; | ||||||
| import { extractSearchableText } from "./workspace-search-utils"; | ||||||
| import { getVirtualPath } from "@/lib/utils/workspace-fs"; | ||||||
| import type { WorkspaceToolContext } from "./workspace-tools"; | ||||||
|
|
@@ -44,6 +44,7 @@ export function createSearchWorkspaceTool(ctx: WorkspaceToolContext) { | |||||
| "Grep search across workspace. All item types match on path/title, including documents, flashcards, PDFs, quizzes, audio, images, websites, and YouTube cards. Types with readable body content or metadata also search that body. Line numbers for content matches align with workspace_read(path, lineStart). include: optional item type filter. path: folder prefix or exact item path; for long items use workspace_read(path, lineStart) on matches. Plain text or regex. Max 100 matches.", | ||||||
| inputSchema: zodSchema( | ||||||
| z.object({ | ||||||
| title: toolTitleField, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Make Prompt for AI agents
Suggested change
|
||||||
| pattern: z.string().describe("Search pattern (plain text or regex)"), | ||||||
| include: z.string().optional().describe('Optional item type filter, e.g. "document", "flashcard", "pdf", "quiz", "audio", "image", "website", or "youtube"'), | ||||||
| path: z.string().optional().describe("Folder prefix (Physics/) or exact item path (Physics/documents/File.md)"), | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,11 +2,31 @@ | |||||||||||||||||||||||
| * Shared utilities for AI tools | ||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import { z } from "zod"; | ||||||||||||||||||||||||
| import { loadWorkspaceState } from "@/lib/workspace/workspace-state-read"; | ||||||||||||||||||||||||
| import type { Item } from "@/lib/workspace-state/types"; | ||||||||||||||||||||||||
| import type { WorkspaceToolContext } from "./workspace-tools"; | ||||||||||||||||||||||||
| import { resolveItemByPath } from "./workspace-search-utils"; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||
| * Shared `title` field for tool inputs whose other arguments are technical | ||||||||||||||||||||||||
| * (regex patterns, raw URLs, generated code). The model writes a short | ||||||||||||||||||||||||
| * present-tense gerund phrase that the UI shows while the tool runs, in | ||||||||||||||||||||||||
| * place of a generic "Loading…" label. | ||||||||||||||||||||||||
| * | ||||||||||||||||||||||||
| * Place this as the FIRST field in a tool's input schema so it streams in | ||||||||||||||||||||||||
| * before the heavier arguments and the loading shell can render it | ||||||||||||||||||||||||
| * immediately during `input-streaming`. | ||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
| export const toolTitleField = z | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Prompt for AI agents |
||||||||||||||||||||||||
| .string() | ||||||||||||||||||||||||
| .min(1) | ||||||||||||||||||||||||
| .max(60) | ||||||||||||||||||||||||
| .optional() | ||||||||||||||||||||||||
| .describe( | ||||||||||||||||||||||||
|
Comment on lines
+21
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
| 'A short present-tense gerund phrase (3–6 words) describing what this tool call is doing in plain language for a non-technical user. Shown in the UI while the tool runs. Examples: "Searching your notes for photosynthesis", "Reading the Wikipedia article", "Computing average grades". No trailing punctuation, no tool names, no jargon (regex, URL, etc.). Strongly encouraged on every call so the user sees meaningful progress instead of a generic loading label.', | ||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||
| * Sanitize tool results for the model's context window. | ||||||||||||||||||||||||
| * | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Make
titleoptional here so older code_execute tool messages still validate on replay.Prompt for AI agents