reach.cluster¶
Modularity-based skill clustering for subagent catalog scoping.
Cluster skills into cohesive subagent scopes using modularity optimization.
ClusterPartition ¶
Bases: BaseModel
Represent a modularity clustering partition of a skill corpus.
Source code in src/reach/cluster.py
cluster_map
property
¶
Map each skill name directly to its assigned cluster identifier.
SkillCluster ¶
Bases: BaseModel
Represent a cohesive cluster of skills for subagent scoping.
Source code in src/reach/cluster.py
cluster_skills ¶
cluster_skills(
skills: Sequence[Skill],
*,
resolution: float = 1.0,
max_clusters: int | None = None,
target_size: int | None = None,
) -> ClusterPartition
Partition skills into cohesive communities using modularity optimization.
Build an adjacency matrix from symmetrized BM25 overlap scores between skill descriptions, then iteratively merge communities that produce the greatest gain in modularity (Q).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skills
|
Sequence[Skill]
|
The corpus of skills to cluster. |
required |
resolution
|
float
|
Resolution parameter (gamma). Higher values yield smaller, more compact clusters; lower values yield larger, merged clusters. Defaults to 1.0. |
1.0
|
max_clusters
|
int | None
|
Optional upper bound on the number of output clusters. |
None
|
target_size
|
int | None
|
Optional soft upper bound on the maximum number of skills per cluster. |
None
|
Returns:
| Type | Description |
|---|---|
ClusterPartition
|
ClusterPartition with identified skill clusters and final modularity score. |