Repository navigation
fix: for simple application, the execution process of skill outputs is disabled, the execution process of skill tools is still displayed - #8188
Conversation
…s disabled, the execution process of skill tools is still displayed
| data["nodes"][10]["properties"]["node_data"]["mcp_output_enable"] = application.mcp_output_enable | ||
| data["nodes"][10]["properties"]["node_data"]["model_setting"] = { | ||
| key: model_setting.get(key) | ||
| for key in ["reasoning_content_enable", "reasoning_content_start", "reasoning_content_end"] |
There was a problem hiding this comment.
Code Review Findings
Potential Issues
-
Missing attribute guard (most important)
application.mcp_output_enableis accessed directly twice. If theApplicationmodel doesn't define this field — or if it'sNonefor existing/legacy records — you'll get anAttributeErroror writenullinto the workflow JSON, which downstream consumers may not expect.- Use
getattr(application, "mcp_output_enable", False)or add a model default (default=False) plus ideally a JSON-schema default.
- Use
-
Duplicated mutation logic
The same block of 7 assignments is repeated for nodes 5 and 10. Every future field addition requires touching two places, which is error-prone (easy to forget one, as could have happened here before).- Refactor into a helper:
def _apply_node_data(node, application, model_id=None, model_params_setting=None): nd = node["properties"]["node_data"] nd.update({ "application_ids": application.application_ids, "tool_ids": application.tool_ids, "dialogue_number": application.dialogue_number, "mcp_output_enable": getattr(application, "mcp_output_enable", False), })
That makes the change a one-liner and prevents drift between the two nodes.
- Refactor into a helper:
-
Magic indices (
data["nodes"][5],[10])
Hardcoded positional indexing is fragile: any reorder in the workflow template silently targets the wrong node.- Prefer locating nodes by
id/type/ name, e.g. build a lookup map, or at least add an assertion on expected node type before mutating.
- Prefer locating nodes by
-
No type/consistency validation
Ensuremcp_output_enableis abool. If it can come from a serializer as string"true"/"false", cast explicitly (bool(...)is unsafe for"false"; use a proper parser).
Optimization Suggestions
- Batch updates: Instead of many separate key assignments, use a single
dict.update()per node — marginally faster and much more readable. - Extract workflow-building into a declarative structure (list of
(node_index/tag, field_mapping)), so adding fields becomes configuration rather than code. - Add unit tests asserting that both nodes receive
mcp_output_enable, including the case where the attribute is absent/None. - Consider schema versioning: if
mcp_output_enableis a new node-data field, gate it behind a schema/version flag so older workflow templates aren't broken.
Summary
Functionally the change looks correct, but it inherits two pre-existing weaknesses (duplication + magic indices) and introduces a new one (unguarded attribute access). Minimal safe fix: use getattr(..., default=False) and deduplicate the node-update logic.
fix: for simple application, the execution process of skill outputs is disabled, the execution process of skill tools is still displayed