GitbookIO/gitbook · warning · Error

There is no previous response to rate.

Error message

There is no previous response to rate.

What it means

Thrown by the submitAssistantFeedback AI tool (useSubmitAssistantFeedbackTool) when it executes with no rateable response available. The tool calls getResponseToRate() and requires both a responseId and a query; if the assistant has not produced (or finished producing) a response yet, the ids are missing and the tool throws before tracking feedback.

Source

Thrown at packages/gitbook/src/components/AI/useSubmitAssistantFeedbackTool.ts:92

                        'ai_chat_tools_submit_assistant_feedback',
                        (rating === 'good'
                            ? tString(language, 'was_this_helpful_positive_label')
                            : tString(language, 'was_this_helpful_negative_label')
                        ).toLocaleLowerCase()
                    ),
                };
            },
            inputSchema: zodToJsonSchema(
                SubmitAssistantFeedbackInputSchema as any
            ) as AIToolDefinition['inputSchema'],
            execute: async (input) => {
                const { trackEvent, language, currentPage, displayContext, getResponseToRate } =
                    ref.current;
                const { rating } = SubmitAssistantFeedbackInputSchema.parse(input);

                const { responseId, query } = getResponseToRate();
                if (!responseId || !query) {
                    throw new Error('There is no previous response to rate.');
                }

                // Attribute to the current page with an explicit context so the event still flushes
                // on pathnames whose ambient insights context has no page (e.g. the embed's
                // assistant tab), matching the submit-page-feedback tool.
                const pageContext: InsightsEventPageContext = {
                    pageId: currentPage?.pageId ?? null,
                    displayContext,
                };

                trackEvent(
                    {
                        type: 'ask_rate_response',
                        query,
                        responseId,
                        rating: rating === 'good' ? 1 : -1,
                    },
                    pageContext,

View on GitHub (pinned to db67585ee2)

Solutions

  1. Prompt/ instruct the model (tool description) that the feedback tool must only be called after answering, ensuring a response exists.
  2. In the tool's execute wrapper, degrade gracefully: return a user-facing message ('Nothing to rate yet') instead of throwing when responseId/query are absent.
  3. Ensure the component invoking the tool receives the responseId from the chat stream (response_finish) and stores it before tools can run.
  4. If it fires consistently, debug getResponseToRate's state wiring — the chat state may never record the last response.

Example fix

// before
const { responseId, query } = getResponseToRate();
if (!responseId || !query) {
    throw new Error('There is no previous response to rate.');
}

// after
const { responseId, query } = getResponseToRate();
if (!responseId || !query) {
    return { success: false, reason: 'no-response-to-rate' };
}
Defensive patterns

Strategy: validation

Validate before calling

const { responseId, query } = getResponseToRate();
if (!responseId || !query) {
    // don't invoke the tool; tell the model there is nothing to rate yet
    return;
}

Type guard

const hasRateableResponse = (
    r: { responseId: string | null; query: string | null } | undefined
): r is { responseId: string; query: string } =>
    !!r && !!r.responseId && !!r.query;

Try / catch

try {
    await submitAssistantFeedbackTool.execute(input);
} catch (error) {
    if (error instanceof Error && error.message === 'There is no previous response to rate.') {
        return { success: false, reason: 'no-response' };
    }
    throw error;
}

Prevention

When it happens

Trigger: The AI invokes the submit_assistant_feedback tool before any response_finish was recorded (no responseId); the tool executes after the conversation state was reset/cleared; getResponseToRate returns null query because no user question is tracked in state; the tool schema is called outside the chat flow that populates the rateable response.

Common situations: A model calling the feedback tool at the start of a session before answering; race where the tool call is processed while the response id hasn't been attached to chat state yet; stale prompt/tool definitions after a version change causing premature tool invocation.

Related errors


AI-assisted analysis of GitbookIO/gitbook@db67585ee2 (2026-08-28). Data as JSON: /api/errors/f3b32ee2ed58ed2e. Report an issue: GitHub.