mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 15:03:31 +00:00
Wrap custom tools with hooks (#248)
This commit is contained in:
parent
95dcd04e7c
commit
74f7e6c9d5
3 changed files with 10 additions and 4 deletions
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Hooks wrap custom tools**: Custom tools are now executed through the hook wrapper, so `tool_call`/`tool_result` hooks can observe, block, and modify custom tool executions (consistent with hook type docs).
|
||||
|
||||
## [0.24.0] - 2025-12-19
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -645,7 +645,7 @@ main.ts
|
|||
|
||||
## Tool Wrapping
|
||||
|
||||
Tools are wrapped with hook callbacks before the agent is created:
|
||||
Tools (built-in and custom) are wrapped with hook callbacks after tool discovery/selection, before the agent is created:
|
||||
|
||||
```
|
||||
main.ts
|
||||
|
|
|
|||
|
|
@ -315,9 +315,6 @@ export async function main(args: string[]) {
|
|||
if (hooks.length > 0) {
|
||||
const timeout = settingsManager.getHookTimeout();
|
||||
hookRunner = new HookRunner(hooks, cwd, timeout);
|
||||
|
||||
// Wrap tools with hook callbacks
|
||||
selectedTools = wrapToolsWithHooks(selectedTools, hookRunner);
|
||||
}
|
||||
|
||||
// Discover and load custom tools from:
|
||||
|
|
@ -344,6 +341,11 @@ export async function main(args: string[]) {
|
|||
selectedTools = [...selectedTools, ...customToolInstances] as typeof selectedTools;
|
||||
}
|
||||
|
||||
// Wrap tools with hook callbacks (built-in and custom)
|
||||
if (hookRunner) {
|
||||
selectedTools = wrapToolsWithHooks(selectedTools, hookRunner);
|
||||
}
|
||||
|
||||
// Create agent
|
||||
const agent = new Agent({
|
||||
initialState: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue