Skip to content
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

Inaccurate response - not valid in APEX #116

Open
lukaszkozminski opened this issue Dec 17, 2024 · 2 comments
Open

Inaccurate response - not valid in APEX #116

lukaszkozminski opened this issue Dec 17, 2024 · 2 comments
Labels
BUG P3 Owned by another team We are maintaining this feedback for visibility but it is not within the control of our team triaged A work item has been created. Now being handled internally.

Comments

@lukaszkozminski
Copy link

Summary

The response from Agentforce is invalid and incompatible with Apex. It includes Java methods like Thread.sleep, which are not available in Apex. Despite pointing out that Thread.sleep is unsupported, it still suggests using nonexistent methods like System.pause.

Steps To Reproduce:

  1. Prompt:
    I would like to implement a class responsible for integration with external service. It should allow to retry the logic in case of any integration error. It should retry 3 times. The fist time it should retry afer 1 minute, second time after 10 minutes and last time after 20 minutes
  2. Prompt:
    There is no Thread.sleep method available in APEX

Expected result

It should suggest using System.enqueueJob(new MyQueueableClass(), delayInMinutes).
First of all it should not suggest not existing methods.

Actual result

Response from Agentforce:

public class ExternalServiceIntegration {
    public static final Integer RETRY_COUNT = 3;
    public static final List<Integer> RETRY_DELAYS = new List<Integer>{1, 10, 20};
    
    public void execute() {
        for (Integer i = 0; i < RETRY_COUNT; i++) {
            try {
                // Implement your integration logic here
                // If successful, break the loop
                break;
            } catch (Exception e) {
                // Handle the exception and log it
                System.debug('Error during integration: ' e.getMessage());
            }
            // If not successful, wait for the specified delay before retrying
            if (i < RETRY_DELAYS.size()) {
                Integer delay = RETRY_DELAYS[i];
                System.debug('Retrying in ' delay + 'inutes...');
                // Sleep for the specified delay
                Thread.sleep(delay * 60 * 1000);
            }
        }
    }
}

Next response:
System.pause(1000); // This will pause the execution for 1000 milliseconds (1 second)

Additional information

agentforce_issue1

Feel free to attach a screenshot.

Salesforce Extension Version in VS Code:

Salesforce Einstein For Developers Version in VS Code:

OS and version:

VS Code version:

@lahernandezb
Copy link

@lukaszkozminski Thank you for submitting the issue. We'll pass this along to our AI Research Team for further analysis.

@lahernandezb lahernandezb added triaged A work item has been created. Now being handled internally. Owned by another team We are maintaining this feedback for visibility but it is not within the control of our team BUG P3 labels Dec 17, 2024
Copy link

git2gus bot commented Dec 17, 2024

This issue has been linked to a new work item: W-17455996

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG P3 Owned by another team We are maintaining this feedback for visibility but it is not within the control of our team triaged A work item has been created. Now being handled internally.
Projects
None yet
Development

No branches or pull requests

2 participants