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

Fix redundant <a> tag #641

Merged
merged 6 commits into from
Feb 12, 2025

Conversation

PaperBoardOfficial
Copy link
Contributor

This PR resolves #640

The issue is that the tags have a single child (the text node) but if the text node is not visible (isTextNodeVisible() returns false) the textnode is returned as null in builDomTree.js and later on when the user prompt is formed, the empty "" is sent to llm. This is increasing the token count and confusing the llm.

I fixed it by adding a check that if tag is and child is null, then don't add the to nodeData in buildDomTree.js
This change won't hamper other cases when has img as child or anything else as child.

before logs
after logs

@MagMueller
Copy link
Collaborator

Awesome thanks - could you quickly resolve the conflict?

@MagMueller MagMueller merged commit f8ceb5a into browser-use:main Feb 12, 2025
2 checks passed
AryamanParida pushed a commit to AryamanParida/browser-use that referenced this pull request Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty <a> tags being sent to llm
2 participants