Skip to content

fix: AI Text Generator Block prompt value handling #9896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

chojuninengu
Copy link

When using the AI Text Generator block, users were unable to create prompt values with similar names (e.g., 'PR-Title' and 'PR-Title-test') as the second value would be instantly removed. This restricted users from specifying prompt variables whose names overlap, which is important for thorough testing and differentiating prompt roles. The fix allows for more flexible naming while still preventing exact duplicates.

Changes 🏗️

  • Modified NodeKeyValueInput component to only check for exact duplicates
  • Added validation to prevent exact duplicate keys while allowing similar key names
  • Preserved values when updating keys
  • Improved key input handling logic in the component

Checklist 📋

For code changes:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • Create a new AI Text Generator block
    • Add a prompt value with key 'PR-Title'
    • Add another prompt value with key 'PR-Title-test' (should work now)
    • Add a prompt value with key 'PR-Title' (should be prevented as exact duplicate)
    • Edit existing prompt value keys to ensure values are preserved
    • Verify that similar but non-identical keys are allowed
    • Test with multiple prompt values to ensure all functionality works as expected

For configuration changes:

  • .env.example is updated or already compatible with my changes
  • docker-compose.yml is updated or already compatible with my changes
  • I have included a list of my configuration changes in the PR description (under Changes)

Fixes #9884

majdyz and others added 2 commits April 25, 2025 23:55
…rent thread (Significant-Gravitas#9878)

There are instances of node executions that were failed and end up stuck
in the RUNNING status due to the execution failed to release the lock:
```
2025-04-24 20:53:31,573 INFO  [ExecutionManager|uid:25eba2d1-e9c1-44bc-88c7-43e0f4fbad5a|gid:01f8c315-c163-4dd1-a8a0-d396477c5a9f|nid:f8bf84ae-b1f0-4434-8f04-80f43852bc30]|geid:2e1b35c6-0d2f-4e97-adea-f6fe0d9965d0|neid:590b29ea-63ee-4e24-a429-de5a3e191e72|-] Failed node execution 590b29ea-63ee-4e24-a429-de5a3e191e72: Cannot release a lock that's no longer owned
```

### Changes 🏗️

Check the ownership of the lock before releasing.

### Checklist 📋

#### For code changes:
- [x] I have clearly listed my changes in the PR description
- [x] I have made a test plan
- [x] I have tested my changes according to the test plan:
  <!-- Put your test plan here: -->
  - [x] Existing CI tests.

(cherry picked from commit ef02272)
@chojuninengu chojuninengu requested a review from a team as a code owner April 29, 2025 11:48
@chojuninengu chojuninengu requested review from Swiftyos and majdyz and removed request for a team April 29, 2025 11:48
@github-project-automation github-project-automation bot moved this to 🆕 Needs initial review in AutoGPT development kanban Apr 29, 2025
@CLAassistant
Copy link

CLAassistant commented Apr 29, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

This PR targets the master branch but does not come from dev or a hotfix/* branch.

Automatically setting the base branch to dev.

@github-actions github-actions bot added platform/frontend AutoGPT Platform - Front end platform/backend AutoGPT Platform - Back end labels Apr 29, 2025
Copy link

deepsource-io bot commented Apr 29, 2025

Here's the code health analysis summary for commits d5dc687..6cd15cc. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ Success
❗ 21 occurences introduced
🎯 18 occurences resolved
View Check ↗
DeepSource Python LogoPython✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@github-actions github-actions bot changed the base branch from master to dev April 29, 2025 11:48
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

9884 - Fully compliant

Compliant requirements:

• Fix bug where prompt values with similar names (e.g., 'PR-Title' and 'PR-Title-test') are removed
• Allow users to define multiple prompt values with unique names, even if one is a substring of another
• Still prevent exact duplicate names

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Validation Timing

The duplicate check is performed after user input, but there's no visual feedback to users when a duplicate key is rejected. Consider adding user feedback when duplicates are detected.

// Check for exact duplicates only
const hasExactDuplicate = newPairs.some((pair, index) => 
  newPairs.findIndex(p => p.key === pair.key) !== index
);

if (!hasExactDuplicate) {
  setKeyValuePairs(newPairs);
  handleInputChange(
    selfKey,
    newPairs.reduce((obj, { key, value }) => ({ ...obj, [key]: value }), {}),
  );
}

Copy link

netlify bot commented Apr 29, 2025

Deploy Preview for auto-gpt-docs ready!

Name Link
🔨 Latest commit 6cd15cc
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/6810f81fd958f40008403b6b
😎 Deploy Preview https://deploy-preview-9896--auto-gpt-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Apr 29, 2025

Deploy Preview for auto-gpt-docs-dev ready!

Name Link
🔨 Latest commit 6cd15cc
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs-dev/deploys/6810f81f9fb8810008a286a2
😎 Deploy Preview https://deploy-preview-9896--auto-gpt-docs-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ntindle ntindle requested review from kcze and removed request for Swiftyos and majdyz April 29, 2025 16:02
@ntindle
Copy link
Member

ntindle commented Apr 30, 2025

Screen.Recording.2025-04-30.at.8.53.00.AM.mov

Copy link
Member

@ntindle ntindle left a comment

Choose a reason for hiding this comment

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

still seeing behavior, see attached video

@github-project-automation github-project-automation bot moved this from 🆕 Needs initial review to 🚧 Needs work in AutoGPT development kanban Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end Review effort 2/5 size/m
Projects
Status: 🚧 Needs work
Status: No status
Development

Successfully merging this pull request may close these issues.

Bug: AI Text Generator Block Removes Prompt Values with Similar Names
4 participants