fix: remove internal tools when creating tools and better Approval gate UX

This commit is contained in:
Alex
2026-04-03 10:36:48 +01:00
parent 8b9e595d85
commit be7da983e7
5 changed files with 25 additions and 4 deletions

View File

@@ -2,6 +2,8 @@ from abc import ABC, abstractmethod
class Tool(ABC):
internal: bool = False
@abstractmethod
def execute_action(self, action_name: str, **kwargs):
pass

View File

@@ -20,6 +20,8 @@ class InternalSearchTool(Tool):
- list_files action: browse the file/folder structure
"""
internal = True
def __init__(self, config: Dict):
self.config = config
self.retrieved_docs: List[Dict] = []

View File

@@ -36,6 +36,8 @@ class ThinkTool(Tool):
The reasoning content is captured in tool_call data for transparency.
"""
internal = True
def __init__(self, config=None):
pass

View File

@@ -19,7 +19,7 @@ class ToolManager:
continue
module = importlib.import_module(f"application.agents.tools.{name}")
for member_name, obj in inspect.getmembers(module, inspect.isclass):
if issubclass(obj, Tool) and obj is not Tool:
if issubclass(obj, Tool) and obj is not Tool and not obj.internal:
tool_config = self.config.get(name, {})
self.tools[name] = obj(tool_config)

View File

@@ -928,13 +928,23 @@ function ToolCallApprovalBar({
</div>
<div className="flex items-center gap-2">
<button
className="bg-primary hover:bg-primary/90 rounded-full px-4 py-1 text-xs font-medium text-white"
onClick={() => onToolAction?.(toolCall.call_id, 'approved')}
className={`rounded-full px-4 py-1 text-xs font-medium transition-colors ${
comment
? 'bg-muted text-muted-foreground cursor-default opacity-50'
: 'bg-primary hover:bg-primary/90 text-white'
}`}
onClick={() => {
if (!comment) onToolAction?.(toolCall.call_id, 'approved');
}}
>
Approve
</button>
<button
className="hover:bg-accent text-muted-foreground rounded-full border px-4 py-1 text-xs font-medium"
className={`rounded-full border px-4 py-1 text-xs font-medium transition-colors ${
comment
? 'border-destructive bg-destructive/10 text-destructive font-semibold'
: 'hover:bg-accent text-muted-foreground'
}`}
onClick={() => {
if (expanded && comment) {
onToolAction?.(toolCall.call_id, 'denied', comment);
@@ -974,6 +984,11 @@ function ToolCallApprovalBar({
className="border-border bg-background w-full rounded-lg border px-3 py-1.5 text-sm"
value={comment}
onChange={(e) => setComment(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter' && comment) {
onToolAction?.(toolCall.call_id, 'denied', comment);
}
}}
/>
</div>
)}