fix(nodes): keep every key of an AND group in parentheses - #1161
Open
MohammadHijjawi97 wants to merge 1 commit into
Open
MohammadHijjawi97 wants to merge 1 commit into
MohammadHijjawi97 wants to merge 1 commit into
Conversation
When a node input expression contains a parenthesised group, the group is evaluated first and its result is spliced back into the expression. The keys were joined with "|", which turns an AND group into an OR: "a & (b & c)" became "a&b|c" and resolved to ["a", "b"], and "(a & b) & c" resolved to just ["a"], so required keys were silently dropped from the node's input. Join the group's keys with "&" so they stay required together. Groups that resolve to a single key (all built-in graph inputs) are unaffected. The same fix is applied to the standalone parse_expression helper.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Node input expressions are resolved by
BaseNode._parse_input_keys: parenthesised groups are evaluated first, and their keys are spliced back into the expression. The keys were joined with|, which turns an AND group into an OR, so required keys are silently dropped:Changes
&, so they remain required together. Groups that resolve to a single key behave exactly as before, e.g.user_prompt & (relevant_chunks | parsed_doc | doc)used by the built-in graphs.utils.parse_state_keys.parse_expressionhelper duplicates this logic, so it gets the same one-line fix.tests/nodes/base_node_test.pyand a case intests/utils/parse_state_keys_test.py.Testing
pytest tests/nodes/base_node_test.py tests/utils/parse_state_keys_test.py: 4 of the new cases fail onpre/beta, and all 6 pass with the fix.pytest tests/graphs/abstract_graph_test.py: 24 passed.test_llm_missing_tokensfails identically on unmodifiedpre/betaand is unrelated.ruff checkon the changed files;black --check/isort --check-onlyon the test files.