Skip to content

[Bug]: AI helper rejects short follow-up answers after assistant replies #2365

Open

Description

@shrinivas-sn

Bug Description

The AI helper treats a short follow-up answer such as “yes” as off-topic even after the assistant asks a question. The frontend sends only previous messages in history, ending with the assistant's model message. isContextualResponse() checks the second-to-last entry, which is the earlier user message, so the contextual answer is rejected before Gemini receives it.

Steps to Reproduce

  1. In the AI helper, ask an on-topic question, such as “Can you help me prepare for coding interviews?”

  2. After the assistant replies with a follow-up question, answer “yes”.

  3. frontend/src/components/AIHepler.jsx builds history from the existing messages state before the current prompt is added to the request. A completed exchange therefore sends roles [user, model].

  4. On current main (a8d14cf46d659f55efd7b79043f8caecc8eb6213), this focused reproduction prints contextual: false and domain: false:

    const { isContextualResponse, isPrepPilotDomain } = require('./backend/utils/domainClassifier');
    const history = [
      { role: 'user', text: 'Can you help me prepare for interviews?' },
      { role: 'model', text: 'Yes. Shall we start with coding?' },
    ];
    console.log({ contextual: isContextualResponse('yes', history), domain: isPrepPilotDomain('yes') });

Expected Behavior

The answer should be recognized as a follow-up to the assistant's question and passed to the AI mentor with the preceding conversation.

Actual Behavior

isContextualResponse() returns false. The domain check also returns false for “yes”, so /api/generate returns its off-topic local-classifier response instead of continuing the conversation. The same result occurs after two or more completed exchanges.

Severity

Medium

Screenshots / Screen Recording

Not captured. The exact frontend history shape and backend helper were checked from source; the focused Node reproduction above was run. A full browser/server test was not run.

Browser

Not browser-specific.

Operating System

Not OS-specific.

Additional Context

The earlier completed #561 / #566 changed the index based on an assumption that history includes the current user prompt. The current AI helper request sends that prompt separately, so the actual contract differs. I found no open issue or PR for this current flow in targeted searches. If this is in scope, please assign it to shrinivas-sn; I can add a focused regression test and fix after confirmation. I would also appreciate confirmation of OSCI'26 eligibility.

Activity

  1. github-actions commented on Oct 12, 2026

    @github-actions

    Thanks for creating this issue!

    If you'd like to work on it, simply comment:

    /claim

    The first person to claim the issue will be assigned automatically.

    Happy contributing!

  2. shrinivas-sn commented on Oct 12, 2026

    @shrinivas-sn
    Author

    /claim

  3. github-actions commented on Oct 12, 2026

    @github-actions

    ✅ @shrinivas-sn has successfully claimed this issue!

    You've been assigned. Happy coding!

    Tip: Please open a Pull Request linked to this issue when you're ready.
    Add Closes #2365 in your PR description.

  4. github-actions commented on Oct 27, 2026

    @github-actions

    This issue has had no activity for 14 days and has been marked as stale. If this is still relevant, please leave a comment or push an update within the next 7 days, otherwise it will be closed automatically to keep the tracker clean.

  5. shrinivas-sn commented on Oct 31, 2026

    @shrinivas-sn
    Author

    PR #2366 has been submitted and is currently awaiting maintainer review.

  6. github-actions commented on Nov 15, 2026

    @github-actions

    This issue has had no activity for 14 days and has been marked as stale. If this is still relevant, please leave a comment or push an update within the next 7 days, otherwise it will be closed automatically to keep the tracker clean.

  7. shrinivas-sn commented on Nov 16, 2026

    @shrinivas-sn
    Author

    Still active and relevant! The fix is implemented, verified, and submitted in PR #2401 (#2401), currently awaiting maintainer review.

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

Metadata

Metadata

Assignees

Labels

claimedThis issue has been claimed by a contributorstale

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions