Merge pull request #862 from triepod-ai/feat/add-tool-annotations

feat: Add tool annotations for improved LLM tool understanding
This commit is contained in:
Michael Panchenko authored and GitHub committed 2026-01-01 19:07:26 +07:00
commit 823e7c6325
2 files changed
+15 -6

No files matched your search

+11 -2
View File
@@ -221,7 +221,16 @@ class SerenaMCPFactory:
def execute_fn(**kwargs) -> str: # type: ignore
return tool.apply_ex(log_call=True, catch_exceptions=True, **kwargs)
annotations = ToolAnnotations(readOnlyHint=not tool.can_edit())
# Generate human-readable title from snake_case tool name
tool_title = " ".join(word.capitalize() for word in func_name.split("_"))
# Create annotations with appropriate hints based on tool capabilities
can_edit = tool.can_edit()
annotations = ToolAnnotations(
title=tool_title,
readOnlyHint=not can_edit,
destructiveHint=can_edit,
)
return MCPTool(
fn=execute_fn,
@@ -232,7 +241,7 @@ class SerenaMCPFactory:
is_async=is_async,
context_kwarg=None,
annotations=annotations,
title=None,
title=tool_title,
)
def _iter_tools(self) -> Iterator[Tool]:
+4 -4
View File
@@ -1,9 +1,9 @@
from typing import Literal
from serena.tools import ReplaceContentTool, Tool
from serena.tools import ReplaceContentTool, Tool, ToolMarkerCanEdit
class WriteMemoryTool(Tool):
class WriteMemoryTool(Tool, ToolMarkerCanEdit):
"""
Writes a named memory (for future reference) to Serena's project-specific memory store.
"""
@@ -52,7 +52,7 @@ class ListMemoriesTool(Tool):
return self._to_json(self.memories_manager.list_memories())
class DeleteMemoryTool(Tool):
class DeleteMemoryTool(Tool, ToolMarkerCanEdit):
"""
Deletes a memory from Serena's project-specific memory store.
"""
@@ -66,7 +66,7 @@ class DeleteMemoryTool(Tool):
return self.memories_manager.delete_memory(memory_file_name)
class EditMemoryTool(Tool):
class EditMemoryTool(Tool, ToolMarkerCanEdit):
def apply(
self,
memory_file_name: str,