Skip to main content
Glama

switch_focus

Switch focus to any task by ID to navigate your workspace, jump between tasks in any order, revisit completed work, or change priorities on the fly.

Instructions

Switch focus to ANY task by ID. The primary way to navigate your task workspace - jump between tasks in any order, revisit completed work, or change priorities on the fly. Current task retains its status, target task becomes current. Use get_big_picture or get_stack_overview to see task IDs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
task_idYesThe ID of the task to switch focus to

Implementation Reference

  • The handler function that executes the switch_focus tool. It calls TaskManager.switch_focus and handles errors.
    async def handle_switch_focus(self, task_id: str) -> Dict[str, Any]:
        try:
            result = self.task_manager.switch_focus(task_id)
            return result
        except ValueError as e:
            return {"error": str(e)}
  • The input schema and Tool definition for the switch_focus tool.
    Tool(
        name="switch_focus",
        description="Switch focus to ANY task by ID. The primary way to navigate your task workspace - jump between tasks in any order, revisit completed work, or change priorities on the fly. Current task retains its status, target task becomes current. Use get_big_picture or get_stack_overview to see task IDs.",
        inputSchema={
            "type": "object",
            "properties": {
                "task_id": {
                    "type": "string",
                    "description": "The ID of the task to switch focus to",
                }
            },
            "required": ["task_id"],
        },
    ),
  • src/server.py:48-75 (registration)
    The tool registration in the server, mapping 'switch_focus' to its handler.
    handler_map = {
        "create_new_task": lambda: handlers.handle_create_new_task(
            arguments["title"], arguments["body"]
        ),
        "extend_current_task": lambda: handlers.handle_extend_current_task(
            arguments["title"], arguments["body"]
        ),
        "get_current_task": handlers.handle_get_current_task,
        "get_big_picture": lambda: handlers.handle_get_big_picture(
            arguments.get("format", "text")
        ),
        "complete_current_task": handlers.handle_complete_current_task,
        "get_completed_tasks": lambda: handlers.handle_get_completed_tasks(
            arguments.get("order", "chronological")
        ),
        "update_current_task": lambda: handlers.handle_update_current_task(
            arguments["body"]
        ),
        "get_stack_overview": handlers.handle_get_stack_overview,
        "peek_context": lambda: handlers.handle_peek_context(
            arguments.get("include_body", False)
        ),
        "list_siblings": lambda: handlers.handle_list_siblings(
            arguments.get("include_body", False)
        ),
        "switch_focus": lambda: handlers.handle_switch_focus(arguments["task_id"]),
        "remove_task": lambda: handlers.handle_remove_task(arguments["task_id"]),
    }
  • The core implementation logic for switching focus to a task by ID, updating statuses and manual current task.
    def switch_focus(self, task_id: str) -> Dict[str, Any]:
        """Switch focus to any pending task by ID."""
        # Find the task in the structure
        target_task: Optional[Task] = None
        for main_task in self.global_tasks:
            if main_task.id == task_id and main_task.status != TaskStatus.COMPLETED:
                target_task = main_task
                break
            for sub_task in main_task.sub_tasks:
                if sub_task.id == task_id and sub_task.status != TaskStatus.COMPLETED:
                    target_task = sub_task
                    break
            if target_task:
                break
    
        if not target_task:
            raise ValueError(f"Task with ID '{task_id}' not found or already completed")
    
        # If it's already the current task, nothing to do
        if target_task == self.current_task:
            return {
                "success": True,
                "message": "Task is already the current focus",
                "task_id": task_id,
            }
    
        # Set old current task to PENDING
        if self.current_task:
            self.current_task.status = TaskStatus.PENDING
    
        # Set new task to CURRENT
        target_task.status = TaskStatus.CURRENT
    
        # Set the manual current task
        self._manual_current_task = target_task
    
        # Return helpful context about the switch
        return {
            "success": True,
            "message": f"Switched focus to task: {target_task.title}",
            "task_id": task_id,
            "new_focus_path": self.get_focus_path(),
        }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It explains key behaviors: 'Current task retains its status, target task becomes current' and that it works with 'ANY task by ID' including completed ones. However, it doesn't address potential side effects, error conditions, or what happens if an invalid ID is provided, leaving some behavioral aspects unclear.

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 appropriately sized with three sentences that each serve a distinct purpose: stating the core function, explaining its role in navigation, and providing usage guidance. It's front-loaded with the primary action. There's minimal redundancy, though the second sentence could be slightly more concise.

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

Completeness4/5

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

Given the tool's moderate complexity (single parameter, no output schema, no annotations), the description provides good contextual coverage. It explains the tool's purpose, usage context, and behavioral effects. The main gap is the lack of output information, but for a focus-switching tool, the behavioral description ('target task becomes current') provides adequate context about the expected outcome.

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?

The schema description coverage is 100%, with the single parameter 'task_id' well-documented in the schema. The description adds minimal value beyond the schema by mentioning 'ANY task by ID' and referring to sibling tools for finding IDs, but doesn't provide additional semantic context about the parameter format or constraints. This meets the baseline for high schema coverage.

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

Purpose5/5

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

The description clearly states the verb ('switch focus') and resource ('ANY task by ID'), specifying it's the primary navigation method for the task workspace. It distinguishes from siblings by mentioning specific alternatives (get_big_picture, get_stack_overview) for finding IDs, rather than overlapping with task manipulation tools like update_current_task or complete_current_task.

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

Usage Guidelines5/5

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

It provides explicit guidance on when to use this tool ('primary way to navigate your task workspace') and when to use alternatives ('Use get_big_picture or get_stack_overview to see task IDs'). The description also clarifies the tool's role in the workflow by mentioning it can be used to 'jump between tasks in any order, revisit completed work, or change priorities on the fly'.

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/cheezcake/aidderall_mcp'

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