Make Cloudflare fallback actually read knowledge-base URLs via server-side fetching#33
Draft
Copilot wants to merge 3 commits into
Draft
Make Cloudflare fallback actually read knowledge-base URLs via server-side fetching#33Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: harshithpabbati <43822585+harshithpabbati@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add option to use Cloudflare GLM model via API
Add Cloudflare Workers AI as Gemini fallback for reply generation
Mar 1, 2026
…wledge base pages Co-authored-by: harshithpabbati <43822585+harshithpabbati@users.noreply.github.com>
Copilot
AI
changed the title
Add Cloudflare Workers AI as Gemini fallback for reply generation
Make Cloudflare fallback actually read knowledge-base URLs via server-side fetching
Mar 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Cloudflare AI fallback was passing knowledge-base URLs as plain strings — the model had no way to read them, so answers relied on training data rather than the actual knowledge base. Any LLM can support URL-based grounding when page content is fetched server-side and injected into the prompt directly.
Changes
app/api/webhooks/reply/route.tsfetchUrlContent(url): fetches a URL (5 s timeout), extracts plain text via JSDOM (existing project dep, same approach ascleanBody), truncates to 4 000 charsPromise.allSettledand injects their text as prompt context — equivalent quality to Gemini's nativeurlContexttoolMAX_FALLBACK_URLS,FALLBACK_URL_CONTENT_LENGTH,URL_FETCH_TIMEOUT_MSREADME.md— Added a note explaining how the fallback handles URLsSecurity
Initial regex-based HTML stripping triggered three CodeQL alerts (
js/bad-tag-filter,js/incomplete-multi-character-sanitization×2). Resolved by using JSDOM for parsing instead.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.