Summary
The before_tool_call plugin hook currently receives toolName and params, but not the model's output that preceded the tool call. This limits the ability to implement compliance patterns.
Use Case
I want to enforce a behavioral pattern where the model must output a classification statement (e.g., CLASSIFY: [task] → Model: [cheap/expensive]) before every tool call. A plugin could:
- Listen to
before_tool_call
- Check if the preceding model output contains the required pattern
- Block the tool call with a helpful message if missing
Current Limitation
// Current event shape
PluginHookBeforeToolCallEvent = {
toolName: string;
params: Record<string, unknown>;
};
No access to what the model said before the tool call.
Proposed Enhancement
Add optional context about the preceding model output:
PluginHookBeforeToolCallEvent = {
toolName: string;
params: Record<string, unknown>;
// New fields
precedingText?: string; // Model output before this tool call
messageId?: string; // Reference to the full message if needed
};
Alternatives Considered
- Behavioral enforcement only: Works but relies on the model remembering the rule
- System prompt injection: Already possible via
before_agent_start, but can't enforce
Impact
This would enable plugins to implement various compliance/governance patterns:
- Cost classification enforcement
- Tool usage audit trails with context
- Custom approval workflows based on what the model is trying to do
Happy to discuss implementation approach if helpful.
Summary
The
before_tool_callplugin hook currently receivestoolNameandparams, but not the model's output that preceded the tool call. This limits the ability to implement compliance patterns.Use Case
I want to enforce a behavioral pattern where the model must output a classification statement (e.g.,
CLASSIFY: [task] → Model: [cheap/expensive]) before every tool call. A plugin could:before_tool_callCurrent Limitation
No access to what the model said before the tool call.
Proposed Enhancement
Add optional context about the preceding model output:
Alternatives Considered
before_agent_start, but can't enforceImpact
This would enable plugins to implement various compliance/governance patterns:
Happy to discuss implementation approach if helpful.