Skip to main content
Glama

Switch Modes

switch_modes
Read-only

Activate specific operational modes such as editing, interactive, planning, or one-shot to adapt the coding agent's behavior for different tasks.

Instructions

Activates the desired modes, like ["editing", "interactive"] or ["planning", "one-shot"].

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modesYesThe names of the modes to activate.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The SwitchModesTool class implements the execution logic (handler) for the 'switch_modes' tool. It accepts a list of mode names, loads the corresponding SerenaAgentMode instances, sets them on the agent, and returns a detailed confirmation including prompts and active tools.
    class SwitchModesTool(Tool, ToolMarkerOptional):
        """
        Activates modes by providing a list of their names
        """
    
        def apply(self, modes: list[str]) -> str:
            """
            Activates the desired modes, like ["editing", "interactive"] or ["planning", "one-shot"]
    
            :param modes: the names of the modes to activate
            """
            mode_instances = [SerenaAgentMode.load(mode) for mode in modes]
            self.agent.set_modes(mode_instances)
    
            # Inform the Agent about the activated modes and the currently active tools
            result_str = f"Successfully activated modes: {', '.join([mode.name for mode in mode_instances])}" + "\n"
            result_str += "\n".join([mode_instance.prompt for mode_instance in mode_instances]) + "\n"
            result_str += f"Currently active tools: {', '.join(self.agent.get_active_tool_names())}"
            return result_str
  • The ToolRegistry singleton automatically discovers and registers all subclasses of Tool in the 'serena.tools' package, including SwitchModesTool, deriving its name 'switch_modes' and marking it as optional.
    def __init__(self) -> None:
        self._tool_dict: dict[str, RegisteredTool] = {}
        for cls in iter_subclasses(Tool):
            if not any(cls.__module__.startswith(pkg) for pkg in tool_packages):
                continue
            is_optional = issubclass(cls, ToolMarkerOptional)
            name = cls.get_name_from_cls()
            if name in self._tool_dict:
                raise ValueError(f"Duplicate tool name found: {name}. Tool classes must have unique names.")
            self._tool_dict[name] = RegisteredTool(tool_class=cls, is_optional=is_optional, tool_name=name)
  • The get_name_from_cls class method in the base Tool class converts 'SwitchModesTool' to the tool name 'switch_modes' used for registration and MCP exposure.
    def get_name_from_cls(cls) -> str:
        name = cls.__name__
        if name.endswith("Tool"):
            name = name[:-4]
        # convert to snake_case
        name = "".join(["_" + c.lower() if c.isupper() else c for c in name]).lstrip("_")
        return name
    
    def get_name(self) -> str:
        return self.get_name_from_cls()
  • In SerenaAgent.__init__, all registered tools including SwitchModesTool are instantiated from the ToolRegistry and stored in self._all_tools for later exposure.
    # instantiate all tool classes
    self._all_tools: dict[type[Tool], Tool] = {tool_class: tool_class(self) for tool_class in ToolRegistry().get_all_tool_classes()}
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations indicate readOnlyHint=true and destructiveHint=false, so the agent knows this is a safe, non-destructive operation. The description adds minimal context by implying activation of modes, but doesn't disclose behavioral traits like what 'activation' entails (e.g., state changes, side effects, or interactions with other tools). It doesn't contradict annotations, but offers little beyond them.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the purpose with examples. It avoids unnecessary words and gets straight to the point. However, it could be slightly more structured by explicitly stating the tool's role in the context of sibling tools, but as-is, it's concise and well-formed.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which handles return values), annotations covering safety, and high schema coverage, the description is minimally adequate. It explains the basic action but lacks context on what modes are, how they interact with other tools, or when to use this. For a tool that likely changes system state (despite readOnlyHint), more detail on behavior and usage would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the parameter 'modes' fully documented in the schema. The description adds value by providing examples (e.g., ['editing', 'interactive']), which clarify the expected format and possible values beyond the schema's generic array of strings. However, it doesn't explain semantics like what modes are available or their effects, keeping it at the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Activates') and resource ('the desired modes'), making the purpose understandable. It provides specific examples like 'editing', 'interactive', 'planning', and 'one-shot' which help illustrate what modes might be. However, it doesn't explicitly differentiate from sibling tools like 'activate_project' or 'get_current_config', which could cause confusion about when to use this versus those alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, context for activation, or exclusions. Given sibling tools like 'activate_project' and 'get_current_config', the lack of differentiation leaves the agent without clear usage rules, relying solely on the tool name and description which are vague about scope.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/oraios/serena'

If you have feedback or need assistance with the MCP directory API, please join our Discord server