think_about_task_adherence
Assess alignment with the original task during extended conversations to ensure focus and clarity. Use this tool to evaluate progress before modifying code to maintain adherence to the intended goal.
Instructions
Think about the task at hand and whether you are still on track. Especially important if the conversation has been going on for a while and there has been a lot of back and forth.
This tool should ALWAYS be called before you insert, replace, or delete code.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/serena/tools/workflow_tools.py:70-84 (handler)The core handler implementation for the 'think_about_task_adherence' tool. The 'apply' method generates and returns a prompt via the prompt factory to guide the agent in evaluating task adherence.class ThinkAboutTaskAdherenceTool(Tool): """ Thinking tool for determining whether the agent is still on track with the current task. """ def apply(self) -> str: """ Think about the task at hand and whether you are still on track. Especially important if the conversation has been going on for a while and there has been a lot of back and forth. This tool should ALWAYS be called before you insert, replace, or delete code. """ return self.prompt_factory.create_think_about_task_adherence()
- src/serena/tools/tools_base.py:359-369 (registration)ToolRegistry automatically discovers and registers all subclasses of Tool in serena.tools modules, deriving the tool name (e.g., 'think_about_task_adherence' from 'ThinkAboutTaskAdherenceTool') and storing them for instantiation by the agent.class ToolRegistry: def __init__(self) -> None: self._tool_dict: dict[str, RegisteredTool] = {} for cls in iter_subclasses(Tool): if not cls.__module__.startswith("serena.tools"): 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)
- Helper method in the generated prompt factory that renders the specific prompt template used by the tool's handler.def create_think_about_task_adherence(self) -> str: return self._render_prompt("think_about_task_adherence", locals())
- src/serena/tools/tools_base.py:120-126 (registration)Class method that derives the MCP tool name 'think_about_task_adherence' from the class name 'ThinkAboutTaskAdherenceTool', used during registration.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