MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / EffectiveToolConfig

Class EffectiveToolConfig

src/harness/tools/filtering.py:18–144  ·  view source on GitHub ↗

Computed effective tools and submodules for a specific context and step. This class encapsulates the logic for determining which tools and submodules are available for a given step, applying both plan-level and step-level filtering rules. Attributes: tools: List of effectiv

Source from the content-addressed store, hash-verified

16
17@dataclass
18class EffectiveToolConfig:
19 """Computed effective tools and submodules for a specific context and step.
20
21 This class encapsulates the logic for determining which tools and submodules
22 are available for a given step, applying both plan-level and step-level
23 filtering rules.
24
25 Attributes:
26 tools: List of effective tool definitions after filtering.
27 submodule_tools: List of effective submodule tool definitions.
28 enabled_submodule_names: List of submodule names that are enabled.
29
30 Example:
31 config = EffectiveToolConfig.compute(
32 all_tools=agent.tools,
33 context=workflow_context,
34 step_config=step.get("task", {}),
35 )
36 available_tools = config.tools + config.submodule_tools
37 """
38
39 tools: List[Dict[str, Any]]
40 submodule_tools: List[Dict[str, Any]]
41 enabled_submodule_names: List[str]
42
43 @classmethod
44 def compute(
45 cls,
46 all_tools: List[Dict[str, Any]],
47 context: Dict[str, Any],
48 step_config: Optional[Dict[str, Any]] = None,
49 ) -> EffectiveToolConfig:
50 """Compute effective tool configuration for a step.
51
52 Applies filtering rules to determine which tools and submodules
53 are available for the current step:
54 - If both plan and step specify enabled tools, uses intersection
55 - If only one specifies, uses that list
56 - If neither specifies, all tools are available
57
58 Args:
59 all_tools: Complete list of available tool definitions.
60 context: Workflow context containing plan-level settings.
61 step_config: Optional step-specific configuration.
62
63 Returns:
64 EffectiveToolConfig with filtered tools and submodules.
65 """
66
67 def normalize_enabled_list(value: Any) -> Optional[List[str]]:
68 if value is None:
69 return None
70 if isinstance(value, (list, tuple, set)):
71 return [str(v) for v in value]
72 return [str(value)]
73
74 def compute_effective_set(
75 plan_key: str,

Callers 2

test_dataclass_fieldsMethod · 0.90
test_empty_configMethod · 0.90

Calls

no outgoing calls

Tested by 2

test_dataclass_fieldsMethod · 0.72
test_empty_configMethod · 0.72