Internal documentation for developers. This page covers the Tools API: tool CRUD, HTTP tool configuration, and built-in AI tool types. Not intended for end users.
Route Map
Tool Types
HTTP Tool Config Schema
Tool Config Storage
All tool configurations are stored asPrisma.InputJsonObject in the Tool.config column. When reading, cast appropriately:
Web Page Summary
Theweb-page-summary tool fetches a URL and uses AI to summarize its content. Key implementation notes:
GET /api/tools/web-page-summaryreturns the latest threeLLMTaskOutputrows wheretype = web_page_summary.POST /api/tools/web-page-summaryrequires theapi-keyheader to matchNEXTAUTH_SECRET.- Request payload is validated with
WebPageSummarySchemaand includesurlplus optionaldate. - Page HTML is loaded through
loadPageContent, stripped with Cheerio, chunked withsplitTextByToken, and summarized withChatModel. - Chunk sizing uses
ModelConfig[modelName].contextWindowTokens * 0.5; keep catalog context sizing oncontextWindowTokens. - JSON output requests use the OpenAI SDK
response_formattype carried byCallInput. - Returns a persisted
LLMTaskOutputpayload with metadata, summary sections, and FAQ data.
YouTube Summary
Theyoutube-summary tool extracts video transcripts and summarizes them:
GET /api/tools/youtube-summaryreturns the latest threeLLMTaskOutputrows wheretype = youtube_summary.POST /api/tools/youtube-summaryis implemented intools/youtube-summary/functions.tsand exposed by the route module.- Request payload is validated with
YoutubeSummarySchema; do not cast parsed payloads toany. - Unauthenticated requests are rate limited with
heavyRateLimiter; authenticated internal calls use theapi-keyheader. - Transcript chunks are sized from
ModelConfig[summaryModel].contextWindowTokens * 0.5. - Model calls are typed as
Omit<CallInput, 'model'>before the concrete model name is attached. - Chapter extraction uses the
youtube_summaryOpenAI tool schema; normal summaries and FAQs use directChatModelcalls. - Returns or upserts a persisted
LLMTaskOutputwith localized transcript, chapters, summary, and FAQ fields depending on options.
Agent Tool Management
When an agent has tools:Known Issues / Gotchas
- HTTP tool secret exposure: The
auth.valuefield stores API keys/tokens. Never return these inGETresponses — mask with***or omit. Only set new values viaPATCH. - HTTP tool injection risk: The
urlandbodyfields support template variables. Validate that variable substitution cannot be used for SSRF (block internal IP ranges:10.x,172.16-31.x,192.168.x,127.x,169.254.x). - Specialist tools (
type: 'agent') use the sameTooltable but have completely differentconfigstructure from HTTP tools. Always checktool.typebefore readingconfig.

