To save resources make it easy to reuse requests in manual testing

Created on 28 October 2025, 3 days ago

Problem/Motivation

This comes from testing and development of Canvas AI but also should apply to other uses

If I am testing/developing Canvas AI I may be working with a file like /canvas/ui/src/components/aiExtension/AiWizard.tsx where I am editing Javascript and that will invoke remote AI call is not super important, expect that it should use reasonable results.

I might enter the prompt, "create a hello world code component" many many times. Every time I do this request it makes a real remote call. Over months of development for many developers this could start to add up not just in costs but in resources we don't need to use. This is probably more of a concern as we think about *all* developers working across the Drupal AI ecosystem.

I could use AI Test Echo provider but it requires me

  1. record the requests using a real provider
  2. switch to using the EchoProvider.
  3. enable the response I won't to use

Realistically I am not going to do this very often.

Proposed resolution

Make it extremely easy to just reuse response from AI provider when manually testing or developing

  1. Add a Automatically reuse results setting to MockSettingsForm
  2. If that setting is enabled LogMockRequests enable the results automatically
  3. Create a new event subscriber for PreGenerateResponseEvent and if a matching result is found call \Drupal\ai\Event\PreGenerateResponseEvent::setForcedOutputObject

Remaining tasks

There a lot of ways this could be improved but it would be nice just to get the bar minimum in and then l look at

  1. Update \Drupal\ai_test\EventSubscriber\LogMockRequests::logPostRequest to use a label provider name and some text to identify it. will make admin/content/ai-mock-provider-result easier to read
  2. Use a view at admin/content/ai-mock-provider-result to allow bulk enabling/disabling/deleting
  3. Add setting to only re-use result based on some criteria, such agent id, etc.

Optional: Other details as applicable (e.g., User interface changes, API changes, Data model changes)

✨ Feature request
Status

Active

Version

1.2

Component

AI Test

Created by

πŸ‡ΊπŸ‡ΈUnited States tedbow Ithaca, NY, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Merge request !979Draft: Resolve #3554853 "Resuse results" β†’ (Open) created by tedbow
  • Pipeline finished with Failed
    3 days ago
    #642485
  • Pipeline finished with Canceled
    2 days ago
    Total: 215s
    #643476
  • Pipeline finished with Success
    2 days ago
    Total: 258s
    #643480
  • Pipeline finished with Failed
    2 days ago
    Total: 223s
    #643556
  • Pipeline finished with Success
    2 days ago
    Total: 221s
    #643630
  • Pipeline finished with Success
    2 days ago
    Total: 207s
    #643656
Production build 0.71.5 2024