Feature: Tool Call Validation Hooks
Summary
Add configurable validation hooks that intercept tool calls before execution, enabling custom validation logic (timestamp verification, data format checks, permission enforcement).
Problem
Real-world Impact: Model Time Drift
In production use (2026-03-08 to 2026-03-09), the AI model calculated timestamps with wrong year (2025 instead of 2026), leading to 18 corrupted records in our Feishu Bitable:
| Incident |
Time |
Corrupted Records |
Error |
| 1 |
2026-03-08 10:26 |
14 |
Year 2025→2026 |
| 2 |
2026-03-08 15:04 |
2 |
Year 2025→2026 |
| 3 |
2026-03-08 23:25 |
1 |
Year 2025→2026 |
| 4 |
2026-03-09 11:50 |
1 |
Year 2025→2026 |
Root Cause: AI models trained on historical data may produce outdated timestamps, especially for UTC millisecond calculations + timezone conversions.
Current Limitation
OpenClaw skills provide guidelines (SKILL.md) but cannot enforce validation before API calls. This is fragile: models may skip validation, especially in multi-turn conversations or when context is long.
Proposed API
Add toolValidationHooks to Gateway config:
{
"toolValidationHooks": {
"feishu_bitable_app_table_record": {
"before": "/path/to/validate-timestamp.js",
"onError": "reject" // or "warn" or "log"
}
}
}
Hook Script Interface
// validate-timestamp.js
module.exports = async function(toolName, params, context) {
if (params.fields && params.fields['日期']) {
const timestamp = params.fields['日期'];
const year = new Date(timestamp).getFullYear();
const currentYear = new Date().getFullYear();
if (Math.abs(year - currentYear) > 1) {
return {
valid: false,
error: `Invalid year: ${year}, expected ${currentYear}±1`,
suggestion: `Use helper: node trade-time-helper.js "YYYY-MM-DD HH:mm:ss"`
};
}
}
return { valid: true };
};
Execution Flow
1. Agent calls tool (e.g., feishu_bitable_app_table_record)
2. Gateway intercepts → runs validation hook
3. If valid → proceed with tool execution
4. If invalid → reject with error message (or warn and continue)
Expected Impact
| Before |
After |
| ❌ Data corruption (18 records) |
✅ 100% prevention |
| ❌ Depends on model compliance |
✅ Mechanically enforced |
| ❌ Post-hoc detection only |
✅ Pre-execution validation |
Benefits:
- Prevent corrupted data before it enters external systems
- Generic mechanism (not limited to timestamps)
- Per-tool or pattern-based configuration
- Non-breaking (opt-in via config)
Implementation Notes
Phase 1:
- Add
toolValidationHooks config schema
- Implement hook execution in Gateway
- Support
before hooks (post hooks can be Phase 2)
- Error handling: reject/warn/log modes
Phase 2 (optional):
- Async validation with timeout
- Hook chaining (multiple validators per tool)
- Context injection (session info, agent ID)
Related
Environment
- OpenClaw: 2026.3.7
- Feishu Plugin: 2026.3.7-beta.1
- Models affected: GLM-4.7, GPT-4, Claude 3.5 (likely all LLMs)
Would the OpenClaw team be open to this feature? Happy to contribute implementation if the design direction is approved.
Feature: Tool Call Validation Hooks
Summary
Add configurable validation hooks that intercept tool calls before execution, enabling custom validation logic (timestamp verification, data format checks, permission enforcement).
Problem
Real-world Impact: Model Time Drift
In production use (2026-03-08 to 2026-03-09), the AI model calculated timestamps with wrong year (2025 instead of 2026), leading to 18 corrupted records in our Feishu Bitable:
Root Cause: AI models trained on historical data may produce outdated timestamps, especially for UTC millisecond calculations + timezone conversions.
Current Limitation
OpenClaw skills provide guidelines (SKILL.md) but cannot enforce validation before API calls. This is fragile: models may skip validation, especially in multi-turn conversations or when context is long.
Proposed API
Add
toolValidationHooksto Gateway config:Hook Script Interface
Execution Flow
Expected Impact
Benefits:
Implementation Notes
Phase 1:
toolValidationHooksconfig schemabeforehooks (post hooks can be Phase 2)Phase 2 (optional):
Related
Environment
Would the OpenClaw team be open to this feature? Happy to contribute implementation if the design direction is approved.