diff --git a/src/cleveragents/actor/compiler.py b/src/cleveragents/actor/compiler.py index 7c381552d..bcdedc1dd 100644 --- a/src/cleveragents/actor/compiler.py +++ b/src/cleveragents/actor/compiler.py @@ -156,11 +156,36 @@ def _map_edge(edge: EdgeDefinition) -> lg_nodes.Edge: def _extract_lsp_bindings(node: NodeDefinition) -> list[LspBinding]: - """Extract LSP bindings from a node config block.""" + """Extract LSP bindings from a node's dedicated lsp_binding field. + + Reads from the typed ``node.lsp_binding`` (NodeLspBinding) field and + converts to LspBinding records. Also checks config dict for backward + compatibility with legacy ``lsp_bindings`` config key. + + Args: + node: The node definition to extract bindings from. + + Returns: + List of LspBinding records for this node. + """ bindings: list[LspBinding] = [] + + # Primary path: read from the dedicated typed field (NodeLspBinding) + if node.lsp_binding is not None: + bindings.append( + LspBinding( + node_name=node.id, + lsp_server_name=node.lsp_binding.server or "", + languages=node.lsp_binding.languages or [], + auto_detect=node.lsp_binding.auto if node.lsp_binding.auto is not None else True, + ) + ) + + # Fallback path: check config dict for backward compatibility raw_bindings = node.config.get("lsp_bindings", []) if not isinstance(raw_bindings, list): return bindings + for entry in raw_bindings: if not isinstance(entry, dict): continue @@ -175,6 +200,7 @@ def _extract_lsp_bindings(node: NodeDefinition) -> list[LspBinding]: auto_detect=entry.get("auto_detect", True), ) ) + return bindings