feat(web): improve agent performance, MCP tools, and much more
Merged
BR
8mo ago+2628+2628+0123456789012345678901234567890123456789-1741-1741-0123456789012345678901234567890123456789
This PR is effectively a re-work of the tools we ship in our MCP server & ask agent. There are many details & changes in this PR, most of which are covered in the changelog. In terms of the impact of this PR:
- Tool outputs have been optimized to minimize the amount of tokens. Impact: thread will use significantly less tokens (~95% reduction in the brief tests I ran)
- Changed
search_codeto look like grep (also renamed it togrep). Agents have a much easier time using understanding and using the grep syntax over our custom search syntax. Impact: The agent will be able to search and find things much more effectively and efficiently. - Added
groupByRepotogrep(prev.search_code) to allow agents to get compact responses that aggregate search results by repo. Impact: Agents are able to get a high-level overview of what terms exist in which repositories without blowing up their context window. This is really helpful when searching over a large number of repos since it gives the agent the ability to narrow down it's search to only repositories that are relevant. - Added
glob, andlistTreetools. Impact: the agent has additional mechanisms for exploring repositories. - Removed the constraint on the search scope selector that required at least one repository to be selected. Impact: it's much easier to search across everything.
Summary
- Introduces a shared
ToolDefinition<TName, TShape, TMetadata>abstraction infeatures/tools/with a unifiedexecute(input, context)signature andToolResult<TMetadata>return shape - All tools (
read_file,list_commits,list_repos,search_code,find_symbol_references,find_symbol_definitions,list_tree) are now defined once and registered with both the Vercel AI agent and the MCP server viatoVercelAIToolandregisterMcpTooladapters - Adapters inject call-site context (
source: 'agent'orsource: 'mcp') into every tool execution isReadOnlyandisIdempotenthints are declared on each tool definition and forwarded to MCPannotationsviaregisterMcpTool- Tool names normalized to snake_case throughout;
toolNamesconstant eliminated in favour ofxDefinition.name - Added
list_treetool to the Vercel AI agent with a UI component in the details card - Tool metadata fields normalized (
repository→repo);webUrladded tosearch_codeoutput - Shared
logger.tsfor tools; debug logging added to all tools using consistent snake_case names - Tool descriptions updated with usage guidance (retry on repo-not-found errors,
list_reposdiscovery,webUrllinking) - Copy-to-clipboard button moved into
ToolHeaderso all tool components get it for free