fix(complete-tool): rm unnecessary files

This commit is contained in:
Sharath 2025-07-19 21:31:16 +05:30 committed by GitHub
parent bafa1becef
commit 1193d11b2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 0 additions and 108 deletions

View File

@ -1,108 +0,0 @@
# Complete Tool Changes Summary
## Overview
Modified the complete tool to behave like the ask tool by accepting `text` and `attachments` parameters, making it more flexible for providing completion summaries and deliverables.
## Backend Changes
### 1. Updated `backend/agent/tools/message_tool.py`
**Changes to the `complete` method:**
- Added `text` parameter (optional): Completion message or summary to present to user
- Added `attachments` parameter (optional): List of files or URLs to attach to the completion message
- Updated OpenAPI schema to include the new parameters
- Updated XML schema mappings to support the new parameters
- Updated function signature: `async def complete(self, text: Optional[str] = None, attachments: Optional[Union[str, List[str]]] = None) -> ToolResult:`
- Added parameter conversion logic to handle single attachment strings
**Updated description:**
- Enhanced tool description to mention including relevant attachments
- Updated example to show usage with text and attachments
### 2. Updated `backend/agent/prompt.py`
**Changes to agent prompts:**
- Modified the rule about sharing results to allow using the complete tool with attachments
- Updated from: "Always share results and deliverables using 'ask' tool with attachments before entering complete state"
- Updated to: "Always share results and deliverables using 'ask' tool with attachments before entering complete state, or include them directly with the 'complete' tool"
## Frontend Changes
### 1. Created `frontend/src/components/thread/tool-views/complete-tool/_utils.ts`
**New utility file:**
- Mirrors the structure of `ask-tool/_utils.ts`
- Provides `extractCompleteData` function to parse text and attachments from tool calls
- Supports both new format (tool_execution) and legacy format parsing
- Handles single attachment strings and arrays
- Includes comprehensive logging for debugging
### 2. Updated `frontend/src/components/thread/tool-views/CompleteToolView.tsx`
**Major changes:**
- Added import for `extractCompleteData` utility
- Added `project` prop to support file attachments
- Added file type detection functions (`isImageFile`, `isPreviewableFile`)
- Updated component to use extracted text and attachments data
- Modified success badge to use actual success state
- Updated content rendering to handle text and attachments like AskToolView
- Added FileAttachment component for proper file display
- Updated empty state condition to include new parameters
- Maintained backward compatibility with existing complete data parsing
**New features:**
- Displays completion text in a formatted markdown box
- Shows attachments in a grid layout with proper file previews
- Supports image files, previewable files, and regular files
- Maintains existing functionality for legacy complete data
## Benefits
1. **Consistency**: Complete tool now has the same parameter structure as ask tool
2. **Flexibility**: Agents can provide completion summaries and deliverables directly
3. **Better UX**: Users can see completion details and attached files in a unified interface
4. **Backward Compatibility**: Existing complete tool calls without parameters still work
5. **Enhanced Communication**: Agents can provide more context when completing tasks
## Usage Examples
### Backend Usage:
```python
# Simple completion (existing behavior)
await message_tool.complete()
# With completion message
await message_tool.complete(text="All tasks completed successfully!")
# With attachments
await message_tool.complete(attachments=["app.js", "docs/README.md"])
# With both text and attachments
await message_tool.complete(
text="Project completed! Here are the deliverables:",
attachments=["app.js", "docs/README.md", "deployment.yaml"]
)
```
### Frontend Display:
- Text appears in a formatted markdown box
- Attachments are displayed in a responsive grid
- Images are shown with previews
- Previewable files (HTML, MD, CSV) are rendered inline
- Regular files show with appropriate icons
## Testing
The changes have been tested to ensure:
- Backward compatibility with existing complete tool calls
- Proper parameter handling (text, attachments, both, or neither)
- Frontend rendering of text and attachments
- File type detection and display
- Success state handling
## Migration Notes
- Existing complete tool calls will continue to work unchanged
- New complete tool calls can optionally include text and attachments
- Frontend will gracefully handle both old and new formats
- No breaking changes to existing functionality