Skip to content

Conversation

@lewistransts
Copy link
Collaborator

@lewistransts lewistransts commented Jul 8, 2025

Add Persistent Tool Auto-Approval System

Summary

This PR introduces a persistent tool auto-approval system that allows users to permanently approve tools across sessions, in addition to the existing session-based approval.

Key Changes

🔧 Enhanced Tool Approval Options

  • New approval option: Added [f]orever option alongside existing [y]es, [n]o, and [a]lways options
  • Persistent storage: Tools approved with "forever" are saved to global config and persist across sessions
  • Session vs Persistent: Clear distinction between session-based ([a]lways) and persistent ([f]orever) approvals

🏗️ Core Implementation

ToolManager (tool_manager.py)

  • Added _load_persistent_auto_approved_tools() method to load saved tools from config
  • Modified constructor to initialize with persistent tools from config
  • Updated reset_approved_tools() to preserve persistent approvals while clearing session-based ones

ConfigManagement (config_management.py)

  • Added get_auto_approval_tools() method to retrieve persistent auto-approved tools
  • Added write_auto_approval_tools() method to add/remove tools from persistent list
  • Enhanced default config structure to include auto_approval_tools array
  • Added proper error handling and logging for config operations

ConsoleUI (console_ui.py)

  • Updated confirmation prompt to clearly distinguish between session and persistent approval
  • Added [f]orever option handler that saves tool to persistent config
  • Improved user feedback messages to clarify approval scope
  • Enhanced error message to include all available options

🔄 Behavioral Changes

Before:

  • Tools approved with [all] were only remembered for the current session
  • Each new session required re-approval of all tools
  • No persistent approval mechanism

After:

  • [a]lways - Session-based approval (existing behavior)
  • [f]orever - Persistent approval across all sessions
  • Tools approved forever are automatically loaded on startup
  • Clear user feedback about approval scope

🛡️ Safety & Reliability

  • Graceful handling of missing or corrupted config files
  • Proper error logging for config operations
  • Backwards compatibility with existing config files
  • Type safety with proper list/dict validation

📋 User Experience

  • Clear, intuitive prompt text explaining approval options
  • Immediate feedback confirming approval scope
  • Consistent behavior across sessions for persistent approvals
  • No breaking changes to existing workflows

Technical Details

Config Structure

{
  "api_keys": {},
  "auto_approval_tools": ["tool1", "tool2", ...]
}

Flow changes

  1. User requests tool execution
  2. System checks both session and persistent approval lists
  3. If not approved, presents 4 options: y/n/a/f
  4. Forever approvals are saved to global config
  5. Next session automatically loads persistent approvals

…for session and forever approval

feat(tool_manager.py): load persistent auto-approved tools from config to maintain user preferences across sessions
feat(config_management.py): add methods to manage auto-approval tools in global config for better user experience
@lewistransts lewistransts requested a review from daltonnyx July 8, 2025 13:23
…proved tools to clean up the codebase

chore(config_management.py): remove commented-out code for ensuring auto_approval_tools key to enhance code clarity
…ainability

chore(tool_manager.py): remove commented-out explanation to streamline code readability
…method to the end of the class for better readability and organization
self.console.print(
Text(
"\nAllow this tool to run? [y]es/[n]o/[all] future calls: ",
"\nAllow this tool to run? [y]es/[n]o/[a]lways in this session/[f]orever (this and future sessions): ",
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be [a]ll (in this session) instead of [a]lways in this session

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

saved_text = Text(
"✓ Tool '", style=RICH_STYLE_YELLOW
)
saved_text.append(tool_use["name"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

merge to 1

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

…mprove clarity

fix(console_ui.py): simplify approved text messages for better readability
fix(config_management.py): return a default configuration structure with global settings when config file is missing or invalid
@daltonnyx daltonnyx merged commit 1b49134 into main Jul 8, 2025
6 checks passed
@lewistransts lewistransts deleted the feature/auto-approve-tools branch July 8, 2025 14:37
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