Skip to content

feat(agent): Add agent mode switching (Standard/Plan/Auto-Accept) - #213

Merged
edenreich merged 10 commits into
mainfrom
claude/issue-212-20251119-1352
Nov 19, 2025
Merged

edenreich merged 10 commits into
mainfrom
claude/issue-212-20251119-1352

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Summary

Implements three operational modes for the agent that can be toggled with Shift+Tab:

  • 🎯 Standard Mode (default): Normal operation with all configured tools and approval checks
  • 📋 Plan Mode: Read-only mode for planning and analysis (only Read/Grep/Tree tools)
  • ⚡ Auto-Accept Mode: All tool executions auto-approved (bypasses all guardrails)

Changes

  • Add AgentMode enum (Standard, Plan, AutoAccept) to domain layer
  • Integrate mode into ApplicationState and StateManager with cycling logic
  • Add Shift+Tab keybinding to cycle modes
  • Create UI mode indicator below input field (only shows for non-Standard modes)
  • Add mode-specific system prompts to guide LLM behavior
  • Implement approval bypass for Auto-Accept mode
  • Add comprehensive documentation to README
  • Regenerate mocks for updated interfaces

Closes #212

Generated with Claude Code

claude Bot and others added 10 commits November 19, 2025 14:02
Implements three operational modes for the agent that can be toggled with Shift+Tab:

- **Standard Mode** (default): Normal operation with all configured tools and approval checks
- **Plan Mode**: Read-only mode for planning and analysis (only Read/Grep/Tree tools)
- **Auto-Accept Mode**: All tool executions auto-approved (bypasses all guardrails)

Changes:
- Add AgentMode enum (Standard, Plan, AutoAccept) to domain layer
- Integrate mode into ApplicationState and StateManager with cycling logic
- Add Shift+Tab keybinding to cycle modes
- Create UI mode indicator below input field (only shows for non-Standard modes)
- Add mode-specific system prompts to guide LLM behavior
- Implement approval bypass for Auto-Accept mode in shouldRequireApproval()
- Inject StateManager into AgentService for mode-aware operations
- Update InputView to display current mode with emoji indicators
- Add comprehensive documentation to README
- Regenerate mocks for updated interfaces

The mode indicator displays:
- 📋 PLAN MODE - Planning only, no execution
- ⚡ AUTO-ACCEPT MODE - All tools auto-approved

All tests passing ✓

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Eden Reich <[email protected]>
This commit fixes the issue where Plan Mode was still showing all tools
to the LLM despite the system prompt instructions. The problem had two
root causes:

1. **Tool filtering not implemented**: The system relied only on system
   prompt instructions to guide the LLM, but didn't actually filter the
   available tools before sending them to the model.

2. **StateManager initialization order bug**: StateManager was being
   initialized AFTER AgentService, causing it to be nil when the agent
   tried to check the current mode.

Changes made:

**Domain Layer:**
- Add `ListToolsForMode(mode AgentMode)` method to ToolService interface

**Service Layer:**
- Implement `ListToolsForMode()` in LLMToolService with Plan mode filtering
  - Plan Mode: Only Read, Grep, and Tree tools
  - Standard/AutoAccept: All enabled tools
- Implement `ListToolsForMode()` in NoOpToolService for interface compliance
- Add debug logging for tool filtering (using logger instead of fmt.Printf)

**Agent Service:**
- Move tool retrieval into the event loop (from static initialization)
- Retrieve current agent mode from StateManager on each iteration
- Create SDK client with mode-filtered tools for each LLM call
- Add debug logging to track mode detection

**Container:**
- Extract StateManager initialization into separate method
- Initialize StateManager BEFORE domain services (fixes nil reference)
- Remove duplicate StateManager initialization

**Mocks:**
- Regenerate FakeToolService with new ListToolsForMode method

The fix ensures that when users switch to Plan Mode:
- Only Read, Grep, and Tree tools are sent to the LLM
- The LLM cannot call Write, Edit, Delete, Bash, or other modification tools
- Mode changes take effect immediately on the next LLM interaction

Signed-off-by: Eden Reich <[email protected]>
…ment

- Add approval state tracking in domain layer
- Implement approval UI components with visual feedback
- Add keybindings for approval actions
- Update agent service to handle approval workflow
- Integrate approval system with chat handler
- Add A2A agent URL configuration
- Implement agent task submission and querying
- Add tool execution with proper error handling
- Improve service layer for agent interactions

Signed-off-by: Eden Reich <[email protected]>
Fixes a nil pointer dereference panic that occurred when EditTool and
MultiEditTool attempted to render diffs in their FormatForLLM methods.

The panic occurred because DiffRenderer was being instantiated with a
nil styleProvider, which caused a segmentation fault when RenderDiff
tried to call GetThemeColor on the nil pointer.

Changes:
- EditTool.FormatForLLM: Initialize themeService and styleProvider
  before creating DiffRenderer
- MultiEditTool.FormatForLLM: Initialize themeService and styleProvider
  in both success and failure code paths

This follows the established pattern used in FormatArgumentsForApproval
methods, ensuring all DiffRenderer instances have a valid styleProvider.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Remove outdated TODO notes about placeholder implementations
- Update tool names to match actual implementation:
  - SubmitTask → A2A_SubmitTask
  - Query → A2A_QueryAgent
  - DownloadArtifacts → A2A_DownloadArtifacts
- Add complete A2A configuration example with all four tools
- Update examples and workflow descriptions to use correct tool names
- Expand tool references in agents configuration documentation

Signed-off-by: Eden Reich <[email protected]>
@edenreich
edenreich merged commit c4d5de1 into main Nov 19, 2025
@edenreich
edenreich deleted the claude/issue-212-20251119-1352 branch November 19, 2025 20:09
inference-gateway-releaser Bot pushed a commit that referenced this pull request Nov 19, 2025
## [0.56.0](v0.55.0...v0.56.0) (2025-11-19)

### 🚀 Features

* **agent:** Add agent mode switching (Standard/Plan/Auto-Accept) ([#213](#213)) ([c4d5de1](c4d5de1)), closes [#212](#212)
* Add interactive tool approval system for chat mode ([#211](#211)) ([68f11ec](68f11ec))
* Update A2A server configuration and UI components ([18c2213](18c2213))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.56.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Improve token efficiency with different modes

1 participant