Conversation
Ask AI was failing on every question with "AI-201 Bad input". Root cause: @docsearch/react v4 has two Ask AI transports, selected by an `agentStudio` flag: agentStudio: false (default) -> https://askai.algolia.com/chat (legacy standalone Ask AI) agentStudio: true -> https://{appId}.algolia.net/agent-studio/1 /agents/{id}/completions (Agent Studio) Our assistant lives in Algolia Agent Studio (the published "MetaMask Documentation Help" agent), but the flag was never set, so the site was posting to the retired legacy backend. That backend cannot resolve an Agent Studio agent ID and returns AI-201. The configured assistantId (REak1eiP5wfp) was also a stale legacy Ask AI ID rather than the Agent Studio agent ID. This is why Ask AI worked when tested from the Algolia dashboard but not on the docs site - the dashboard was exercising Agent Studio directly. Changes: 1. docusaurus.config.js - askAi.assistantId updated to the Agent Studio agent ID. 2. src/theme/SearchBar/index.tsx (new) - swizzled wrapper that injects `agentStudio: true` into askAi for the search modal. 3. src/theme/Root.tsx - passes `agentStudio` to DocSearchSidepanel. Why the flag isn't just in docusaurus.config.js: @docusaurus/theme-search-algolia@3.10.2 validates themeConfig.algolia.askAi with a closed Joi schema (assistantId, indexName, apiKey, appId, searchParameters.facetFilters, suggestedQuestions). Adding `agentStudio` there fails the build with `"algolia.askAi.agentStudio" is not allowed`. SearchBar lets props override themeConfig and forwards the whole askAi object to DocSearchModal untouched, so the wrapper is the supported way to get the flag through. Both files carry comments explaining this and noting the wrapper can be deleted once Docusaurus' schema accepts `agentStudio` (or DocSearch v5 makes Agent Studio the default). Note the wrapper reads askAi from themeConfig rather than from props: Navbar/Content renders <SearchBar /> with no props, and the themeConfig merge happens inside the original SearchBar, downstream of the wrapper. Known upstream bug, not introduced here: after this fix answers stream and render correctly, but a spurious second request fires and fails with "422 Conversation must end with a user message or resolved tool results", which DocSearch paints as a red "Chat error" banner above the correct answer. Agent Studio does not set `providerExecuted: true` on tool events in its ai-sdk-5 compatibility stream (verified - tool-input-start, tool-input-available and tool-output-available all omit it), so DocSearch's unconditional `sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls` concludes the client owns the server-side search tool call and auto-resubmits a conversation ending in an assistant message, which the API correctly rejects. There is no supported option to disable that auto-resubmit and @docsearch/react@5.0.5 still sets it unconditionally, so a version bump does not help. Reported to Algolia; tracking separately rather than patching node_modules. Verification: `POST {appId}.algolia.net/agent-studio/1/agents/{agentId} /completions?stream=true&compatibilityMode=ai-sdk-5` with no request to askai.algolia.com/chat/token.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Code blocks in Ask AI answers rendered as unstyled, low-contrast text: the
copy button overlapped the first line and long lines wrapped mid-URL.
DocSearch renders fenced blocks through its own marked renderer as:
<div class="DocSearch-CodeSnippet">
<button class="DocSearch-CodeSnippet-CopyButton">...</button>
<pre><code class="language-tsx">...</code></pre>
</div>
@docsearch/css ships no styling for that <pre>/<code> at all - only
`position: relative` on the wrapper plus the copy button chrome - so the
snippet inherited whatever the surrounding answer styles happened to set.
Snippets now match the site's own code blocks (theme/_prism-code.scss):
`--general-black-light` surface, `--inline-code-font`, `--general-gray` text,
horizontal scroll instead of wrapping, and top padding that clears the copy
button. Applied globally rather than scoped to a container so it covers both
the search modal and the Ask AI sidepanel.
Two things worth noting:
- The existing sidepanel rules force `code { color: #373739 !important }` in
light mode, which is unreadable on the dark snippet surface. The snippet
`code` colour is therefore set with matching specificity and !important,
scoped under both sidepanel colour modes.
- DocSearch does not syntax highlight. The marked renderer only emits a
`language-*` class, with no Prism/highlight.js pass, so this change covers
contrast, typography and layout - not token colours.
Also folds in the DocSearch CSS from PR #3052 (branch `ai-fixes`), which
overlaps this branch: `.DocSearch-Button` margin/transition, and
`.DocSearch-Container` z-index to lift the modal above the fixed navbar. Kept
in _doc-search.scss rather than a separate src/theme/SearchBar/styles.css so
all DocSearch styling stays in one place.
Not copied from #3052: its `:root` `--docsearch-primary-color` /
`--docsearch-text-color` pair. This file already overrides both per colour
mode, and has those exact two lines commented out on purpose at the top;
re-adding them at `:root` would leak a purple primary to DocSearch surfaces
rendered outside `.DocSearch`. Its blanket `.DocSearch-Button-Key
{ padding: 0 }` is included but is largely inert, since
`.DocSearch-Button-Key:first-child` in custom.scss sets padding with
!important.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 94a9561. Configure here.
Member
Author
|
Closing in favor of #3052 |
This branch was successfully deployed
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.

Description
Ask AI was failing on every question with "AI-201 Bad input".
Root cause: @docsearch/react v4 has two Ask AI transports, selected by an
agentStudioflag:agentStudio: false (default) -> https://askai.algolia.com/chat
(legacy standalone Ask AI)
agentStudio: true -> https://{appId}.algolia.net/agent-studio/1
/agents/{id}/completions (Agent Studio)
Our assistant lives in Algolia Agent Studio (the published "MetaMask Documentation Help" agent), but the flag was never set, so the site was posting to the retired legacy backend. That backend cannot resolve an Agent Studio agent ID and returns AI-201. The configured assistantId (REak1eiP5wfp) was also a stale legacy Ask AI ID rather than the Agent Studio agent ID.
This is why Ask AI worked when tested from the Algolia dashboard but not on the docs site - the dashboard was exercising Agent Studio directly.
Changes:
agentStudio: trueinto askAi for the search modal.agentStudioto DocSearchSidepanel.Why the flag isn't just in docusaurus.config.js:
@docusaurus/theme-search-algolia@3.10.2 validates themeConfig.algolia.askAi with a closed Joi schema (assistantId, indexName, apiKey, appId, searchParameters.facetFilters, suggestedQuestions). Adding
agentStudiothere fails the build with"algolia.askAi.agentStudio" is not allowed. SearchBar lets props override themeConfig and forwards the whole askAi object to DocSearchModal untouched, so the wrapper is the supported way to get the flag through. Both files carry comments explaining this and noting the wrapper can be deleted once Docusaurus' schema acceptsagentStudio(or DocSearch v5 makes Agent Studio the default).Note the wrapper reads askAi from themeConfig rather than from props: Navbar/Content renders with no props, and the themeConfig merge happens inside the original SearchBar, downstream of the wrapper.
Known upstream bug, not introduced here: after this fix answers stream and render correctly, but a spurious second request fires and fails with "422 Conversation must end with a user message or resolved tool results", which DocSearch paints as a red "Chat error" banner above the correct answer. Agent Studio does not set
providerExecuted: trueon tool events in its ai-sdk-5 compatibility stream (verified - tool-input-start, tool-input-available and tool-output-available all omit it), so DocSearch's unconditionalsendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCallsconcludes the client owns the server-side search tool call and auto-resubmits a conversation ending in an assistant message, which the API correctly rejects. There is no supported option to disable that auto-resubmit and @docsearch/react@5.0.5 still sets it unconditionally, so a version bump does not help. Reported to Algolia; tracking separately rather than patching node_modules.Verification:
POST {appId}.algolia.net/agent-studio/1/agents/{agentId} /completions?stream=true&compatibilityMode=ai-sdk-5with no request to askai.algolia.com/chat/token.Issue(s) fixed
Fixes #
Preview
Checklist
External contributor checklist
Note
Low Risk
Documentation-site Algolia/Ask AI configuration and theme CSS only; no auth, data, or payment paths.
Overview
Fixes Ask AI failing with AI-201 Bad input by targeting the MetaMask Documentation Help Agent Studio agent instead of the retired
askai.algolia.combackend.Config:
themeConfig.algolia.askAi.assistantIdis updated to the Agent Studio agent UUID, with comments noting whyagentStudiocannot live indocusaurus.config.js(Docusaurus’ closed Joi schema rejects unknownaskAikeys).Runtime wiring: A new swizzled
SearchBarwrapper mergesagentStudio: trueintoaskAifor the search modal, andRoot.tsxpasses the same flag toDocSearchSidepanel, so both entry points hit{appId}.algolia.net/agent-studio/.../completions.UI:
_doc-search.scssadds styling for Ask AI fenced code (.DocSearch-CodeSnippet), inlinecodein answers, DocSearch button spacing, and a higher modalz-indexabove the navbar.Reviewed by Cursor Bugbot for commit 94a9561. Bugbot is set up for automated code reviews on this repo. Configure here.