Skip to content

feat(ai): defer standalone code-mode tools behind toolSearch - #1119

Closed
janburzinski wants to merge 1 commit into
usenotra:mainfrom
janburzinski:feat/ai-sdk-tool-search
Closed

janburzinski wants to merge 1 commit into
usenotra:mainfrom
janburzinski:feat/ai-sdk-tool-search

Conversation

@janburzinski

@janburzinski janburzinski commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds AI SDK toolSearch() to the standalone chat. The ~21 read-only code-mode tools (GitHub, Linear, Granola, posts, GEO, skills, web search) are now registered with deferLoading: true and discovered on demand via a new searchTools tool, instead of inlining all signatures into the code_mode tool description (~15k chars / ~3.8k tokens → ~540 chars per request, multiplied by up to 50 steps per generation).

  • withStandaloneCodeMode registers searchTools (callable directly and via code_mode — discovery requires a shared caller) and enables toolDiscovery: "conversation", so discovered tools are announced in catalog messages while the provider-visible tool list stays stable for prompt caching
  • System prompt teaches the discover-then-call flow; chat UI gets searchTools copy
  • MCP lazy runtime (searchMcpTools/activateMcpTools) intentionally unchanged — it needs DB-persisted per-session activation, which per-generation toolSearch discovery cannot replace
  • Tests cover the provider-visible tool set, catalog contents, and a search→discovery step flow; mutation-checked (removing deferLoading, the caller routing, or conversation mode turns them red)

Screenshot/Recording (if applicable)

Attach a screenshot or recording of the change. This is optional, but can help reviewers understand the change. You can use Cap to record a video.

Checklist
  • I ran a self-review before opening this PR
  • I ran formatting/linting/type checks locally
  • I updated docs when behavior or setup changed
  • I only added comments where the logic is not obvious
  • I have used conventional commits for the PR title and commit messages
  • I did not use AI to write the code in this PR or have disclosed that I did

Summary by cubic

Deploys standalone code-mode tools behind AI SDK toolSearch, so the ~21 read-only tools are discovered on demand instead of inlined in the code_mode description. This cuts prompt size from ~15k chars to ~540 chars per request and keeps the provider-visible tool list stable for prompt caching.

  • Registers a new searchTools tool; the model calls it, then gets the matching tools in the next code-mode capability update.
  • Updates the system prompt and chat UI copy to teach the discover-then-call flow.
  • Leaves the MCP lazy runtime unchanged; it still needs per-session activation that toolSearch can't replace.
  • Adds tests for the provider-visible tool set, catalog messages, and a search→discovery step flow.

Written for commit fe1f04e. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@janburzinski is attempting to deploy a commit to the Notra Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
vercel Bot temporarily deployed to Preview – notra-ui September 17, 2026 19:46 Inactive
@vercel
vercel Bot temporarily deployed to Preview – notra-web September 17, 2026 19:46 Inactive
@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
notra-ui Skipped Skipped Sep 17, 2026 7:46pm UTC
notra-web Skipped Skipped Sep 17, 2026 7:46pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no concrete correctness, security, or repository-rule violations identified.

Summary

The PR moves standalone read-only code-mode tools behind AI SDK tool discovery to reduce repeated prompt size while preserving sandboxed execution.

  • Registers searchTools as both a direct and code-mode discovery caller.
  • Marks standalone code-mode tools for deferred loading and announces discoveries through conversation capability updates.
  • Updates model instructions and chat UI copy for the discovery workflow.
  • Adds tests covering the initial provider-visible tool set and search-to-discovery sequence.

Diagram

sequenceDiagram
    participant M as Model
    participant S as searchTools
    participant C as Capability Catalog
    participant CM as code_mode
    participant T as Deferred Read-only Tool

    M->>S: Search by capability keywords
    S->>C: Discover matching deferred tools
    C-->>M: Next-step capability update
    M->>CM: Run program using tools.name(input)
    CM->>T: Execute discovered tool
    T-->>CM: Return read-only data
    CM-->>M: Return selected result fields
Loading

Reviews (1) · Last reviewed commit: "feat(ai): defer standalone code-mode too..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant