Skip to content

Conversation

@nullchimp
Copy link
Owner

This pull request introduces significant enhancements to tool management and API functionality, along with updates to tool descriptions and UI integration. The changes improve the modularity and usability of tools, refine API responses, and enhance the user interface to display tool information effectively.

Tool Management Enhancements:

  • Added methods enable_tool, disable_tool, and get_tools to the Agent class for managing tool states and retrieving tool information.
  • Modified the Chat class to ensure tools are unique, track their enabled state, and dynamically filter enabled tools during query processing. [1] [2]
  • Introduced enable and disable methods in the Tool class to manage tool activation state.

Query Processing Improvements:

  • Updated the process_query method in Agent to return a list of tools used during query execution. [1] [2]
  • Enhanced the process_tool_calls method in Chat to track and return the names of tools used during tool calls. [1] [2]

API Updates:

  • Added endpoints for listing tools (/tools) and toggling tool states (/tools/toggle) in api/routes.py. [1] [2]R1)
  • Introduced new Pydantic models (ToolInfo, ToolsListResponse, ToolToggleRequest, ToolToggleResponse) to support tool-related API responses.

Tool Description and Parameter Updates:

  • Updated descriptions and parameters for tools such as github_search, google_search, list_files, read_file, and write_file to provide more detailed and user-friendly information. [1] [2] [3] [4] [5]

UI Changes:

  • Added usedTools property to the Message interface and integrated tool-related UI elements (toolsHeader, toolsList) into the ChatApp class in chat.ts. [1] [2]

Modifies the agent to track which tools are used during a query.
The used tools are returned as part of the API response
and displayed in the chat UI. This allows users to see
which tools the agent utilized to formulate its response.
Removes the text-transform style that forced tool tags to be capitalized.
This allows tool tags to be displayed as they are defined, improving consistency.
Implements API endpoints for listing and toggling tools, allowing users to enable or disable tools dynamically.

Introduces the ability to enable or disable individual tools within the agent's chat functionality.
This allows for greater control over the agent's capabilities and resources.
Enhances the agent's tool management by adding try-except blocks to the enable_tool and disable_tool methods, preventing exceptions from halting execution.

Refactors the API to correctly iterate through tool information.

Modifies the chat logic to properly define tools when sending them to the language model and ensures unique tool entries.

Enhances the UI by adding a tools section with toggle functionality, allowing users to enable or disable tools.
Improves the clarity and detail of tool descriptions for better user understanding.

Refactors the UI to include a toggle all tools feature and displays tool configuration as active/total.

Adds a new test suite to validate UI tools configuration functionality.
Improves the descriptions of the google_search, list_files, read_file, and write_file tools to provide more context and detail about their functionality, security measures, and usage. This enhances understanding and usability.

Updates base_dir and relative paths descriptions in file tools.
Copilot AI review requested due to automatic review settings June 23, 2025 22:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances tool lifecycle management, extends API routes for tool operations, refines tool metadata, and integrates tool toggling in the UI.

  • Introduces enable_tool, disable_tool, and get_tools in Agent/Chat
  • Adds /tools and /tools/toggle endpoints with corresponding Pydantic models
  • Updates UI (chat.ts, index.html, styles.css) to display, toggle, and style tools
  • Expands tool descriptions and parameter schemas for write_file, read_file, list_files, google_search, and github_search

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/core/llm/chat.py Tool state methods, filtering disabled tools, debug prints
src/api/routes.py & models.py New list/toggle tool endpoints and models
src/ui/chat.ts, index.html, styles.css UI elements and styling for tools panel
src/tools/*.py Detailed tool descriptions and parameter updates
src/agent.py Agent wrappers for tool operations
tests/ Updated tests for tool metadata and QueryResponse.used_tools
Comments suppressed due to low confidence (1)

src/api/routes.py:24

  • No tests currently cover the new /tools and /tools/toggle endpoints. Please add pytest AsyncClient tests to verify the listing and toggling behavior, including error cases.
@router.get("/tools", response_model=ToolsListResponse)

// Update the tools configuration text to show active/total format
const toolsLabelSpan = this.toolsHeader.querySelector('.tools-label span');
if (toolsLabelSpan) {
toolsLabelSpan.textContent = `Tools Configuration [${enabledCount}/${totalCount}]`;
Copy link

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI uses square brackets around the tools count ([x/y]) while tests and other displays use angle brackets (<x/y>). To maintain consistency, consider switching to angle brackets or updating tests to match this format.

Suggested change
toolsLabelSpan.textContent = `Tools Configuration [${enabledCount}/${totalCount}]`;
toolsLabelSpan.textContent = `Tools Configuration <${enabledCount}/${totalCount}>`;

Copilot uses AI. Check for mistakes.

def _set_tool_state(self, tool_name: str, active = True) -> None:
for tool in self.tools:
print(f"Checking tool: {tool.name} against {tool_name} ")
Copy link

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This debug print may clutter logs in production. Consider removing it or gating it behind a verbose/debug flag.

Suggested change
print(f"Checking tool: {tool.name} against {tool_name} ")
if is_debug():
print(f"Checking tool: {tool.name} against {tool_name} ")

Copilot uses AI. Check for mistakes.

const data = await response.json();
return data.response || 'Sorry, I couldn\'t process your request.';
console.log('API Response Data:', data); // Debug log
Copy link

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove or disable this debug console.log in production builds to avoid leaking potentially sensitive response payloads.

Suggested change
console.log('API Response Data:', data); // Debug log
if (process.env.NODE_ENV !== 'production') {
console.log('API Response Data:', data); // Debug log
}

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +45
tool.disable()
if active:
tool.enable()
Copy link

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The disable-then-enable pattern is redundant when activating a tool. Consider simplifying to if active: tool.enable() else: tool.disable() for clarity.

Suggested change
tool.disable()
if active:
tool.enable()
if active:
tool.enable()
else:
tool.disable()

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +66
def enable_tool(self, tool_name: str) -> None:
try:
self.chat.enable_tool(tool_name)
except Exception as e:
return False
return True

def disable_tool(self, tool_name: str) -> None:
Copy link

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type should be annotated as -> bool to reflect that this method returns True/False, improving type clarity.

Suggested change
def enable_tool(self, tool_name: str) -> None:
try:
self.chat.enable_tool(tool_name)
except Exception as e:
return False
return True
def disable_tool(self, tool_name: str) -> None:
def enable_tool(self, tool_name: str) -> bool:
try:
self.chat.enable_tool(tool_name)
except Exception as e:
return False
return True
def disable_tool(self, tool_name: str) -> bool:

Copilot uses AI. Check for mistakes.
@nullchimp nullchimp merged commit 0933431 into main Jun 24, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants