fix: improve AI corrective prompt clarity and add global next_node_id validation
- Rewrote CORRECTIVE_PROMPT_TEMPLATE to clearly distinguish option→child vs action→sibling next_node_id semantics with concrete examples - Added global check in ai_tree_validator that action next_node_ids actually reference existing nodes in the tree (was silently unchecked) - Added max_tokens truncation warning to branch_detail logger - Added test for action next_node_id referencing nonexistent node Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -124,6 +124,13 @@ class TestReferenceIntegrity:
|
||||
errors = validate_generated_tree(tree)
|
||||
assert any("non-existent child" in e for e in errors)
|
||||
|
||||
def test_action_next_node_id_references_nonexistent_node(self):
|
||||
"""Action next_node_id pointing to a node that doesn't exist anywhere in the tree."""
|
||||
tree = _make_valid_tree()
|
||||
tree["children"][1]["next_node_id"] = "ghost-node"
|
||||
errors = validate_generated_tree(tree)
|
||||
assert any("ghost-node" in e for e in errors)
|
||||
|
||||
def test_duplicate_option_ids(self):
|
||||
tree = _make_valid_tree()
|
||||
tree["options"][0]["id"] = "same"
|
||||
|
||||
Reference in New Issue
Block a user