Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Conversation

@hschawe
Copy link
Collaborator

@hschawe hschawe commented Aug 20, 2025

Jira:

Changes

  • Normalize URL in message formatting so that the LLM doesn't have to handle parsing and passing really long URLs as tool args (cases when there's long query strings, hash fragments)
  • Adds labels to origin rules for formatting front matter in a more maintainable manner

Comment on lines 68 to 75
const originToLabelRules = ORIGIN_RULES.filter(
(rule) => rule.label !== undefined
);
originToLabelRules.forEach((rule) => {
if (parsedCustomData.originCode === rule.code) {
frontMatter.client = rule.label as string;
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

logically this seems correct, but i suspect there's a more efficient way to do this without the filter, forEach, and casting with as string.

for instance, i think you could precompute a map of originCodeLabels, where it's like:

interface OriginCodeLabels {
  [code: string]: string // the label
}

// ex: 
const originCodeLabels = {
  GEMINI_CODE_ASSIST: "Gemini Code Assist",
  VSCODE: "MongoDB VS Code extension"
}
// you can compute the above with `ORIGIN_RULES.reduce(...)`

then, in this location update your code to be:

const maybeOriginLabel = originCodeLabels[parsedCustomData.originCode]
if (maybeOriginLabel) {
  frontMatter.client = maybeOriginLabel
}

}

// Some origin codes have a label to add to the front matter
const originToLabelRules = ORIGIN_RULES.filter(
Copy link
Collaborator

Choose a reason for hiding this comment

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

pls add test(s) for this new behavior

Copy link
Collaborator

@mongodben mongodben left a comment

Choose a reason for hiding this comment

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

generally looks good, small back 2 u

hschawe and others added 2 commits August 20, 2025 14:29
Co-authored-by: Ben Perlmutter <90647379+mongodben@users.noreply.github.com>
Copy link
Collaborator

@mongodben mongodben left a comment

Choose a reason for hiding this comment

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

lgtm w/ small suggestion

Co-authored-by: Ben Perlmutter <90647379+mongodben@users.noreply.github.com>
@hschawe hschawe merged commit 003cec9 into main Aug 20, 2025
2 checks passed
@hschawe hschawe deleted the EAI-1149 branch August 20, 2025 20:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants