HITL Implementation for action tools#21
Conversation
|
@sajeerzeji please review our changes |
There was a problem hiding this comment.
Missing Documentation (High Priority)
- No README updates explaining HITL configuration
- Create a PR for https://github.com/toolpack-ai/toolpack-documentation to document all
hitlimplementation including config structure, API Documentation foraddBypassRule(),removeBypassRule(), andreloadConfig(), and bypass rule patterns and best practices, and all available tools with their descriptions.
|
No Automated Tests (High Priority)
|
sajeerzeji
left a comment
There was a problem hiding this comment.
Type Safety Concerns (Medium Priority)
In @/packages/toolpack-sdk/src/toolpack.ts:575:
const { loadConfig, discoverConfigPath } = require('./providers/config.js');Using require() loses type safety. Should use ES6 imports.
Recommendation:
import { loadConfig, discoverConfigPath } from './providers/config.js';|
Error Handling Gaps (Medium Priority)
Recommendation: Add error handling and validation: export async function addBypassRule(options: AddBypassRuleOptions): Promise<void> {
try {
// ... existing code ...
fs.writeFileSync(configPath, JSON.stringify(config, null, 4), 'utf-8');
} catch (error) {
throw new SDKError(`Failed to add bypass rule: ${error.message}`, 'CONFIG_WRITE_ERROR');
}
} |
|
Potential Race Condition (Low Priority) await addBypassRule({ ... });
toolpack.reloadConfig(activeConfigPath || undefined);If multiple confirmations happen simultaneously, config writes could conflict. Recommendation: Consider adding a config write lock or queue. 6. Inconsistent Naming (Low Priority)
Recommendation: Document that bypass rules use |
|
Inconsistent Naming (Low Priority)
Recommendation: Document that bypass rules use |
|
Missing Edge Cases (Low Priority)
Current code handles this well at line 262: if (tool.confirmation && bypass.levels?.includes(tool.confirmation.level))But could add validation warnings. |
|
Github Workflows are failing, take a look |
|
All PR review items have been fixed (excluding documentation): Completed Fixes:
All tests passing ✅ |
|
Added a PR for Documentation: toolpack-ai/toolpack-documentation#3 |
Description
This PR implements Human-in-the-Loop (HITL) tool-level confirmation for high-risk action tools. The system requires user confirmation before executing potentially destructive operations, providing safety guardrails while allowing granular bypass rules for trusted workflows.
fixes #5
Key Features:
confirmationfield to tool definitions withlevel(high/medium),reason, andshowArgsoff,high-only,all- configurable viahitl.confirmationModehitl.bypassconfigTools with HITL Confirmation:
exec.run,exec.run-shell,exec.run-background,fs.write-file,fs.delete-file,fs.delete-dir,fs.move,fs.replace-in-file,fs.batch-write,http.delete,http.post,http.put,db.delete,db.update,coding.multi-file-edit,coding.refactor-rename,diff.applydb.insertBug Fixes:
hitl.enabledis now treated astrueby default when undefined (previously bypassed all tools)write_fileanddelete_fileto prevent misuseFixes # (issue)
Type of change
How Has This Been Tested?
Manual Testing:
fs.delete_filefor "delete/remove" requests vsfs.write_filewith empty contenthitl.enabledis undefined, confirmation is active (not bypassed)Checklist:
npm run lint)