Skip to content

Asktim Summary in search results - #3994

Merged
shanbady merged 23 commits into
mainfrom
shanbady/asktim-summary
Sep 29, 2026
Merged

shanbady merged 23 commits into
mainfrom
shanbady/asktim-summary

Conversation

@shanbady

@shanbady shanbady commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

Closes https://github.com/mitodl/hq/issues/13558

Description (What does it do?)

This PR adds an "AskTim summary" to the search results. The component leverages the existing recommendation bot endpoint with a prefilled query/instructions so it renders appropriately.

Screenshots (if appropriate):

Screenshot 2026-09-25 at 3 49 36 PM Screenshot 2026-09-25 at 3 49 44 PM

How can this be tested?

  1. checkout this branch
  2. in learn-ai checkout the same branch name (shanbady/asktim-summary -> Asktim Summary in search results learn-ai#88)
  3. in frontend.env set NEXT_PUBLIC_LEARN_AI_SEARCH_SUMMARY_ENDPOINT=http://open.odl.local:8065/ai/http/search_summary_agent/
  4. manually set the feature flag to true
  5. rebuild and restart your watch container
  6. search for something and note the asktim summary
  7. clicking "show more" opens up the sidebar to continue the conversation.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

OpenAPI Changes

44 changes: 0 error, 24 warning, 20 info

View full changelog

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@Ferdi

Ferdi commented Sep 25, 2026

Copy link
Copy Markdown

what is the prefilled query instruction?

@Ferdi

Ferdi commented Sep 25, 2026

Copy link
Copy Markdown

in the drawer there is numbers: 1,2

what are those for?

@shanbady

Copy link
Copy Markdown
Contributor Author

The prefilled prompt:

  • Give me courses I might find interesting if I search "${query}". Start with "here are some courses". Do not attempt to continue the conversation. Keep it brief.

Its not clear what the numbers should actually do (in the figma they turn red and have a tooltip when hovered).

@Ferdi

Ferdi commented Sep 25, 2026

Copy link
Copy Markdown

I see what you are trying to do.

The main reason we are doing this is to offer personalized recommendation, because search is not

so we'd really like for them to continue conversation with asktim, hopefully finding what they are looking for.

you might be bothered by asktim asking "tell me more.."

perhaps it gives some recommendation first, and then says "if you tell me more.."
what do you think thiink?

@shanbady

Copy link
Copy Markdown
Contributor Author

we could do that. we can consider either always ending strictly with "if you tell me more.." etc or leave it to the bot continue in some context specific way

@shanbady

Copy link
Copy Markdown
Contributor Author

something like this
Screenshot 2026-09-25 at 4 27 27 PM

@shanbady
shanbady marked this pull request as ready for review September 25, 2026 21:02
@shanbady
shanbady requested a review from a team as a code owner September 25, 2026 21:02
Copilot AI balanced review requested due to automatic review settings September 25, 2026 21:02
@shanbady shanbady added the Needs Review An open Pull Request that is ready for review label Sep 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Shared thread state and streaming-error handling can produce incorrect recommendation conversations and blank overviews.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 3 Medium severity

Open (3)
What changed in this PR

Adds a feature-flagged AskTIM-generated course overview to search results, with a drawer for follow-up conversation.

Changes:

  • Adds the AI overview UI, prompt configuration, and analytics.
  • Reuses recommendation-chat request configuration.
  • Adds feature flagging, environment validation, and tests.
File Description
env/​frontend.local.example.env Documents the optional prompt override.
frontends/​main/​validateEnv.js Registers the prompt environment variable.
frontends/​main/​src/​common/​feature_flags.ts Adds the search overview flag.
frontends/​main/​src/​page-components/​AiChat/​AiRecommendationBotDrawer.tsx Exposes shared recommendation-chat configuration.
frontends/​main/​src/​page-components/​SearchDisplay/​SearchDisplay.tsx Inserts the overview into search results.
frontends/​main/​src/​page-components/​SearchDisplay/​AiSearchOverview.tsx Implements overview generation and follow-up drawer.
frontends/​main/​src/​page-components/​SearchDisplay/​AiSearchOverview.test.tsx Tests overview behavior and configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread frontends/main/src/page-components/SearchDisplay/AiSearchOverview.tsx Outdated
Comment thread frontends/main/src/page-components/SearchDisplay/AiSearchOverview.tsx Outdated
@Ferdi

Ferdi commented Sep 25, 2026

Copy link
Copy Markdown

@shanbady i think that's much better

shanbady and others added 2 commits September 27, 2026 21:25
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Refactor response handling to check for error messages and improve readability.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI and others added 2 commits September 28, 2026 02:18
Co-authored-by: shanbady <196425+shanbady@users.noreply.github.com>
Co-authored-by: shanbady <196425+shanbady@users.noreply.github.com>
Copilot AI and others added 2 commits September 28, 2026 04:58
Co-authored-by: shanbady <196425+shanbady@users.noreply.github.com>
Co-authored-by: shanbady <196425+shanbady@users.noreply.github.com>
Co-authored-by: shanbady <196425+shanbady@users.noreply.github.com>
@mbertrand mbertrand self-assigned this Sep 28, 2026

@mbertrand mbertrand left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure piggybacking on the recommendation bot is the best approach. It mixes two different things: a learner choosing to ask AskTIM about courses, and an automatic summary on every search. A couple of side effects:

  • Threads: the recommendation bot keeps its thread in a cookie. Each search starts a new summary thread (clear_history) and points that cookie at it, so the learner's next message in the regular AskTIM drawer continues the summary thread, prompt instructions included.
  • Rate limit: the summary shares the recommendation_bot limit, which on prod is 20/day anonymous and 30/day logged in. Every search uses one, so after ~20 searches an anonymous user gets "You have reached the maximum number of chat requests…" as the summary. learn-ai returns that as a normal 200, so it isn't caught as an error. It also blocks the regular AskTIM chat for the rest of the day.

Might be better to give the summary its own consumer in learn-ai. It probably doesn't need a new bot, just a subclass of RecommendationBotHttpConsumer with its own ROOM_NAME and throttle_scope, a route, and a ConsumerThrottleLimit row with a significantly higher limit. That gives it its own cookie and its own limit, keeps summary traffic out of the recommendation bot's usage numbers, and avoids polluting the main page's AskTIM drawer with the summary's prompt & chat messages.

@mbertrand mbertrand added Waiting on author and removed Needs Review An open Pull Request that is ready for review labels Sep 28, 2026
@shanbady

Copy link
Copy Markdown
Contributor Author

@mbertrand this should be ready for another look. I updated the PR with new instructions and created the learn-ai PR

@shanbady
shanbady requested a review from mbertrand September 29, 2026 13:44
@shanbady shanbady added Needs Review An open Pull Request that is ready for review and removed Waiting on author labels Sep 29, 2026
Comment thread frontends/main/src/page-components/SearchDisplay/AiSearchOverview.tsx Outdated
shanbady and others added 2 commits September 29, 2026 10:31
…iew.tsx

Co-authored-by: Matt Bertrand <mrbertrand@gmail.com>

@mbertrand mbertrand left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, ol-infrastructure will need a PR for setting NEXT_PUBLIC_LEARN_AI_SEARCH_SUMMARY_ENDPOINT if it doesn't already

@mbertrand mbertrand added Waiting on author and removed Needs Review An open Pull Request that is ready for review labels Sep 29, 2026
@shanbady
shanbady enabled auto-merge (squash) September 29, 2026 17:58
@shanbady
shanbady merged commit 34172cb into main Sep 29, 2026
14 checks passed
@shanbady
shanbady deleted the shanbady/asktim-summary branch September 29, 2026 18:33
@odlbot odlbot mentioned this pull request Sep 29, 2026
1 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants