mirror of
https://github.com/langgenius/dify.git
synced 2026-10-04 13:47:55 +08:00
fix(dify-builder): ground model on all model-bearing nodes, carry branch handles, clean test lint
Final consolidated fix wave from whole-branch review of the Real Build +
Edit Cognition slice:
- _ground now overwrites the model dict on ANY create_node whose config
carries a model dict (llm, question-classifier, parameter-extractor),
not just "llm", so a drifted/hallucinated provider/name on those other
node types no longer flows through ungrounded.
- to_intents now carries a generator edge's sourceHandle/targetHandle
into the connect intent's args (source_handle/target_handle) so
branching nodes (if-else, question-classifier) wire onto the correct
port instead of collapsing onto the default handle; edges without
handles still produce bare {from_node, to_node} args.
- Cleared the 17 ruff errors (PT018/E302/E306/E501) across the slice's
test files by splitting composite asserts, adding missing blank
lines, and wrapping long lines -- no assertions weakened, no noqa.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
a07dc0e766
commit
cd5fb6bbf0
7 files changed
+130
-18
No files matched your search
@@ -68,7 +68,8 @@ def test_build_form_fields_whitelists_and_coerces_type():
|
||||
]
|
||||
)
|
||||
assert [f.key for f in fields] == ["a", "b"]
|
||||
assert fields[0].type == "select" and fields[0].options == ["x"]
|
||||
assert fields[0].type == "select"
|
||||
assert fields[0].options == ["x"]
|
||||
assert fields[1].type == "text" # unknown type coerced to text
|
||||
|
||||
|
||||
@@ -416,7 +417,8 @@ def test_governance_automatic_learns_and_reaches_complete():
|
||||
res = handle_governance_feedback(env, Turn(actor=_actor()), *repo.get_session(s.id))
|
||||
assert res.next == PcState.BUILD_COMPLETE
|
||||
kinds = [i.kind for i in res.items]
|
||||
assert "build_learning" in kinds and "summary" in kinds
|
||||
assert "build_learning" in kinds
|
||||
assert "summary" in kinds
|
||||
assert "notice" in kinds
|
||||
assert env.agent.learn_calls == 1 # seam called for automatic
|
||||
|
||||
@@ -454,7 +456,8 @@ def test_governance_ask_rests_at_await_learning_with_pending_card():
|
||||
res = handle_governance_feedback(env, Turn(actor=_actor()), *repo.get_session(s.id))
|
||||
assert res.next == PcState.BUILD_AWAIT_LEARNING
|
||||
bl = [i for i in res.items if i.kind == "build_learning"][0]
|
||||
assert bl.payload["policy"] == "ask" and bl.payload["state"] == "pending"
|
||||
assert bl.payload["policy"] == "ask"
|
||||
assert bl.payload["state"] == "pending"
|
||||
assert getattr(env.agent, "learn_calls", 0) == 0 # not learned until accepted
|
||||
|
||||
|
||||
@@ -474,7 +477,8 @@ def test_await_learning_accept_learns_and_completes():
|
||||
)
|
||||
assert res.next == PcState.BUILD_COMPLETE
|
||||
kinds = [i.kind for i in res.items]
|
||||
assert "decision" in kinds and "summary" in kinds
|
||||
assert "decision" in kinds
|
||||
assert "summary" in kinds
|
||||
assert "notice" in kinds
|
||||
assert env.agent.learn_calls == 1
|
||||
|
||||
|
||||
@@ -195,4 +195,5 @@ def test_placeholder_learn_from_build_returns_descriptor():
|
||||
from core.dify_builder.placeholder_agent import PlaceholderAgent
|
||||
|
||||
out = PlaceholderAgent().learn_from_build("summarize a PDF", {}, ["step"], ["llm"])
|
||||
assert isinstance(out, str) and out != ""
|
||||
assert isinstance(out, str)
|
||||
assert out != ""
|
||||
Reference in new issue
Block a user