fix: improve tool call 'Ask' permission handling with proper logging and error handling#36
Closed
fix: improve tool call 'Ask' permission handling with proper logging and error handling#36
Conversation
Greptile OverviewGreptile SummaryThis PR makes two primary improvements to the codebase: 1. Enhanced 'Ask' Permission Handling (
2. Timeout Constant Centralization
Additional Enhancements
All changes follow Rust best practices with proper error handling, clear documentation, and maintain backward compatibility. Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| src/cortex-engine/src/agent/handler.rs | Improved Ask permission handling with comprehensive documentation, debug logging, and proper error handling for event send operations |
| src/cortex-common/src/timeout.rs | New module centralizing timeout constants with comprehensive documentation and validation tests |
| src/cortex-engine/src/tools/handlers/batch.rs | Added per-tool timeout support to prevent single tools from blocking batch execution, renamed constant for clarity |
| src/cortex-exec/src/runner.rs | Updated to use centralized timeout constants from cortex-common |
Sequence Diagram
sequenceDiagram
participant Caller as Tool Executor
participant Handler as MessageHandler
participant EventTx as Event Channel
participant Session as Session Handler
participant User as User
Caller->>Handler: handle_tool_execution(profile, tool_call, event_tx)
Handler->>Handler: Check tool permission
alt Permission: Allow
Handler-->>Caller: Ok(true) - Proceed with execution
else Permission: Deny
Handler-->>Caller: Err(Internal) - Execution forbidden
else Permission: Ask
Handler->>Handler: Log debug message
Handler->>EventTx: send(ToolCallPending event)
alt Send Success
EventTx->>Session: ToolCallPending event
Session->>User: ExecApprovalRequest (protocol)
Handler-->>Caller: Ok(false) - Wait for approval
User->>Session: Approval response
Session->>Caller: Retry execution
else Send Failure
Handler-->>Caller: Err(Internal) - Failed to send approval request
end
end
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the handling of the 'Ask' permission case in tool call validation. The
handle_tool_executionmethod now has clearer documentation about return value semantics, proper logging when user approval is requested, and error handling for the event send operation.Changes
let _ =Verification
cargo check -p cortex-engine cargo test -p cortex-engine --lib -- handler