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

Ai collab feedback loop upgrades #23517

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

seanimam
Copy link
Contributor

@seanimam seanimam commented Jan 9, 2025

Description

The error messages produced from attempting an invalid modify edit are being used as part of the feedback loop for an LLM so that when it makes an invalid error, it gets a failure message and description as to why it failed. Until now, these error messages were simply what the shared tree library produced, which may be helpful for developers but loses meaningful context for an LLM looking at what it has done in the last via a prompt.

  • agentEditReducer.ts - Catches errors during the modify switch case and replaces the error message with a context rich one.
  • agentEditingReducer.spec.ts - Refactors tests to have a describe block just for various 'modify' tree edit test cases & adds new cases for when the new error messages would be thrown.
  • utils.ts - Adds new helper methods for determining what the closest match for an invalid field would be. This helps with providing a 'did you mean to use the field xxx' message
  • utils.spec.ts - Adds tests for new helper methods for finding the closest match to a given string.

Reviewer Guidance

  • Analyze the updated messaging in the prompt snapshots for different types of failed modifications. LMK if you see a missed invalid modify case.
  • Analyze my use of schema extraction for field/leafnodes in building the message

… 'modify' edit tests in agentEditReducer.spec.ts
@seanimam seanimam requested review from a team and Copilot January 9, 2025 17:03
@github-actions github-actions bot added area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct base: main PRs targeted against main branch labels Jan 9, 2025

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • packages/framework/ai-collab/src/test/explicit-strategy/snapshots/Prompt_Regression_Snapshot_Tests/Editing_System_Prompt_With_Plan_With_Log.snap: Language not supported
  • packages/framework/ai-collab/src/test/explicit-strategy/snapshots/Prompt_Regression_Snapshot_Tests/Editing_System_Prompt_With_Plan_With_Log_With_Failed_Edits.snap: Language not supported
function createInvalidModifyFeedbackMsg(
modifyEdit: Modify,
treeNode: TreeNode,
errorType: "NONEXISTENT_FIELD" | "INVALID_TYPE",
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT:
I know there's only two types of errorType but can we make this an enum or object?

As we expand the usage of createInvalidModifyFeedbackMsg() in other treeEdit.types we should be having more errorTypes besides NONEXISTENT_FIELD or INVALID_TYPE right?

}

messageSuffix = ` The node's field you selected for modification \`${modifyEdit.field}\` does not exist in this nodes schema. The set of available fields for this node are: \`[${nodeFieldNames.map((field) => `'${field}'`).join(", ")}]\`.${closestPossibleMatchForFieldMessage}`;
} else if (errorType === "INVALID_TYPE") {
Copy link
Contributor

Choose a reason for hiding this comment

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

For now, we can make this else.

"str": "testStr",
"vectors": [
{
"id": (view.root.vectors[0] as Vector).id,
Copy link
Contributor

Choose a reason for hiding this comment

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

I see id is expected for vectors but not for primitive values such as string or bool. Is this expected? Does idGenerator() generate and embed id to non-primitive nodes?

);
});

it("modify edit with non existent field fails", () => {
Copy link
Contributor

@jikim-msft jikim-msft Jan 15, 2025

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but this test is passing in my local environment.

Screenshot 2025-01-14 at 17 45 37

Also, I think it might be useful to add a test case of a root node with multiple fields of identical Levenshtein distance (so a maybe have fields x1 and x2 and try to modify x3). And verify that the error log has good readability with multiple values.


for (const candidate of possibleMatches) {
const distance = levenshteinDistance(input, candidate);
if (distance < bestDistance) {
Copy link
Contributor

@jikim-msft jikim-msft Jan 15, 2025

Choose a reason for hiding this comment

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

Doesn't this condition only honor the first-seen candidate and disregard other candidates with same Levenshtein distance?

Can we return an array containing all the candidates and use string concatenation in the createInvalidModifyFeedbackMsg()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants