Automators: "Edit when changed" ignored in "Advanced Mode (Token)"

Created on 23 February 2025, about 1 month ago

Problem/Motivation

"Edit when changed" is ignored in "Advanced Mode (Token)" for the Automator module.
When content is saved, the automated field value does not update when it already contains a value even if "Edit when changed" is checked.

Steps to reproduce

  1. Create a text field to a content type.
  2. Enable AI Automator (assumes the module is installed, and provider is being set up)
  3. Set: Advanced Mode (Token)
  4. Check: Edit when changed
  5. Edit prompt to generate a random result
  6. Configure other relevant fields to see immediate results
  7. Save
  8. Create a node with the automated field
  9. Make sure the value is populated
  10. Save node again
  11. The value is the same! But we expected subsequent saving to change the value because the prompt generates a random value and "Edit when changed" is checked.

Proposed resolution

See if "Edit when changed" is checked when saving in Advanced Mode.

Remaining tasks

Merge the patch.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

1.0

Component

AI Automators

Created by

🇪🇪Estonia ragnarkurm

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

Merge Requests

Comments & Activities

  • Issue created by @ragnarkurm
  • 🇹🇹Trinidad and Tobago xamount
  • First commit to issue fork.
  • Pipeline finished with Success
    about 1 month ago
    Total: 219s
    #433374
  • 🇬🇧United Kingdom MrDaleSmith

    Can recreate the issue and confirm that the patch resolves it. RTBC. I've added the PR to a MR to make it easier for the maintainers.

  • 🇩🇪Germany marcus_johansson

    I think the issue is my description of this checkbox is bad and a missing description written by a native speaker might be part of a bug issue.

    What the checkbox is suppose to do, is to look at any context field that exists and see if they got changed - then the automator should run again.

    So if you have a article text field and you have a summary field that is automatically populated with automators. If this is checked, the idea is that if you change the article text field, then the summary should be recreated.

    Having it run everytime a node gets updated would be bad, if you have automatic updates of nodes for whatever reasons, since it can end up costing you a lot of money.

    I'm thinking if we should even hide this on advanced mode, since it would be quite hard to check if token values have changed?

    I'll set this issue to active again. Sorry about the confusion.

  • 🇬🇧United Kingdom MrDaleSmith

    I think the issue is that if you use token mode and one of the inputs does change, your content isn't regenerated. We need SOME way of preventing that happening, otherwise this is a once only generation task and that's going to be confusing for people/slightly useless.

  • 🇧🇬Bulgaria valthebald Sofia

    Bumping the version

  • 🇨🇦Canada ydahi Waterloo, Canada

    Patch works as expected on: Drupal 10.4.4, AI 1.0.5.

    It will re-generate on node save - even if no field values are changed.

    This, in my use case, is better than no-regeneration at all. As pointed out by others, a full solution will include some sort of check of changed fields before re-gen/no-re-gen.

    Side note: I've altered my prompt to attempt to preseve any existing generated content if it's still relevant - this seems to be helping reduce the unexpected behaviour of the entire content changing on edit/save.

  • 🇮🇳India annmarysruthy

    On applying the current MR, the automated field values update on each node save if 'Edit when changed' checkbox is enabled. This is not a recommended practice. Also the checkbox is labelled 'Edit when changed', the user is not warned that content of automated fields changes everytime on node save.

    Proposed Resolutions:

    1. Retrieve tokens used in prompt and check if token values used have changed - This is a tough one
    2. On selecting 'Advanced Mode(Token)' ,Hide 'Edit when changed' checkbox or Rename the label and description of checkbox, so that user will know that on enabling the checkbox, the automated field value changes on every edit and this adds to load'
  • 🇮🇳India prashant.c Dharamshala

    I agree with #7 🐛 Automators: "Edit when changed" ignored in "Advanced Mode (Token)" Active .

    Since multiple tokens might be used, checking each token for changes would be challenging. Some tokens, like date/time tokens, will always have a different value, making validation even harder.

    Instead, we could refine the checkbox label and description to better communicate its function. Additionally, we can include a note explaining the implications of enabling this option. By default, the checkbox should remain disabled, allowing site builders to enable it based on their specific needs.

    I suggest something like:

    Checkbox label: "Auto-Update on Change"

    Description for checkbox: "By default, the initial value or manually set value remains unchanged, even if the base text field is updated. Check this option to automatically update the value whenever the base text field changes.
    Note: Enabling this may trigger multiple calls to the LLM, potentially increasing API usage and costs."

    Thankyou

Production build 0.71.5 2024