Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
d8a43d3
feat(hooks): adding outbound messagesent hook
vincentkoc Feb 5, 2026
495a8cd
feat(hooks): outbound messagesent hooks
vincentkoc Feb 5, 2026
9bae626
chore(hooks): wiring session keys to heatbeat hooks
vincentkoc Feb 5, 2026
7ce8b01
chore(hooks): wiring sessionkey to outbound session hooks
vincentkoc Feb 5, 2026
b22aca7
chore(hooks): wiring sessionkey to messaging hooks
vincentkoc Feb 5, 2026
8e5caac
chore(hooks): includes and type changes
vincentkoc Feb 5, 2026
1a1e6b0
feat(hooks): adding runAfterToolCallHook
vincentkoc Feb 5, 2026
f427ed2
feat(hooks): adding runAfterToolCallHook
vincentkoc Feb 5, 2026
eafd8c0
docs(hooks): updating documentation on hooks
vincentkoc Feb 5, 2026
0ddfb55
feat(hooks): add compaction events
vincentkoc Feb 5, 2026
c98ac13
feat(hooks): add missing agent internal hooks
vincentkoc Feb 5, 2026
f8bf9f8
feat(hooks): add context pruning hooks
vincentkoc Feb 5, 2026
bbffe4b
feat(hooks): add internal tool events
vincentkoc Feb 5, 2026
915d87c
feat(hooks): add shutdown events
vincentkoc Feb 5, 2026
0e8924f
docs(hooks): update hooks docs
vincentkoc Feb 5, 2026
df3af67
Update pi-tools.before-tool-call.test.ts
vincentkoc Feb 5, 2026
d2f7ee3
chore: lint
vincentkoc Feb 5, 2026
df41c92
test(hooks): lint and extend hooks
vincentkoc Feb 5, 2026
7b34881
Update pi-tools.before-tool-call.ts
vincentkoc Feb 5, 2026
9c6e99a
test(hooks): extend hooks
vincentkoc Feb 5, 2026
33661c6
Merge branch 'vk/otel-plugin-hooks' of https://github.com/vincentkoc/…
vincentkoc Feb 5, 2026
fe56190
chore: lint
vincentkoc Feb 5, 2026
2029fef
Merge branch 'main' into vk/otel-plugin-hooks
vincentkoc Feb 5, 2026
1b01ec4
chore(cicd): improve formatter to show issues
vincentkoc Feb 5, 2026
3cc4480
chore: fix and patch various greptile and cicd issues
vincentkoc Feb 5, 2026
e2866b0
chore(cicd): formatter
vincentkoc Feb 5, 2026
b421db2
chore: testing diff on formatter to find root cause
vincentkoc Feb 5, 2026
9773f67
Merge branch 'main' into vk/otel-plugin-hooks
vincentkoc Feb 5, 2026
ca02f69
fix: formateer to match cidcd behaviour
vincentkoc Feb 5, 2026
c4e90b9
Merge branch 'vk/otel-plugin-hooks' of https://github.com/vincentkoc/…
vincentkoc Feb 5, 2026
78dc13a
Merge branch 'main' into vk/otel-plugin-hooks
vincentkoc Feb 5, 2026
6cc249a
fix(hooks): greptile fixes
vincentkoc Feb 5, 2026
8593a77
chore: reverse lint with updated formatter
vincentkoc Feb 5, 2026
d9f5d63
fix: formatter isseues
vincentkoc Feb 5, 2026
8c569ef
fix: lint package to meet test req
vincentkoc Feb 5, 2026
7c05fe3
chore: tsgo fix
vincentkoc Feb 5, 2026
1bf50ee
chore: lint
vincentkoc Feb 5, 2026
d85b34a
Revert "chore: lint"
vincentkoc Feb 5, 2026
22f1f9d
fix: formatter yaml
vincentkoc Feb 5, 2026
6f2cf78
chore: reverse temporary fix
vincentkoc Feb 5, 2026
ab2e0c9
Merge branch 'main' into vk/otel-plugin-hooks
vincentkoc Feb 5, 2026
5788e5a
chore: greptile
vincentkoc Feb 5, 2026
bfc2b6f
chore: tsgo error
vincentkoc Feb 5, 2026
8f91e1b
chore: greptile improvements
vincentkoc Feb 5, 2026
3cd840c
chore: tsgo fix on await type
vincentkoc Feb 5, 2026
867f28d
chore: lint and tsgo types for greptile
vincentkoc Feb 5, 2026
98b8475
chore: fix tests to async
vincentkoc Feb 5, 2026
5ed1933
Update deliver.ts
vincentkoc Feb 5, 2026
0587a0f
chore: greptile fix
vincentkoc Feb 5, 2026
0975922
chore: greptile seqByRun fix
vincentkoc Feb 5, 2026
5d39d01
Update send.test.ts
vincentkoc Feb 5, 2026
0ca91b1
fix: sessionkey normalization across all hooks
vincentkoc Feb 5, 2026
e7c0802
fix: further sessionkey normalization
vincentkoc Feb 5, 2026
a198819
chore: fix issues in tests due to context seq change
vincentkoc Feb 5, 2026
920a4a0
chore: fix duplicate event emitter
vincentkoc Feb 5, 2026
159c215
Update deliver.ts
vincentkoc Feb 5, 2026
f40f14a
chore: greptile patch
vincentkoc Feb 5, 2026
002be12
chore: greptile client toolid
vincentkoc Feb 5, 2026
d07c7bd
chore: greptile patch
vincentkoc Feb 5, 2026
7b86300
chore: greptile issues on surrogate toolids
vincentkoc Feb 6, 2026
ac0abba
Update pi-tools.before-tool-call.test.ts
vincentkoc Feb 6, 2026
3ea5e4f
Merge branch 'main' into vk/otel-plugin-hooks
vincentkoc Feb 6, 2026
cce73ca
chore: greptile reqs
vincentkoc Feb 6, 2026
368838f
fix: failing security audit test on windows
vincentkoc Feb 6, 2026
1e34848
fix: upstream tests failures blocking merge
vincentkoc Feb 6, 2026
a13e93d
Merge branch 'main' into vk/otel-plugin-hooks
vincentkoc Feb 6, 2026
9192c40
fix: use UUID when no toolcallId
vincentkoc Feb 6, 2026
899854b
chore: reesolve test issues
vincentkoc Feb 6, 2026
d1c83d9
chore: sessionid fallbacks greptile
vincentkoc Feb 6, 2026
0ecf223
chore: greptile
vincentkoc Feb 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(hooks): add internal tool events
  • Loading branch information
vincentkoc committed Feb 5, 2026
commit bbffe4b096e5dbb92f71b8f27fee20b3a574a50a
26 changes: 26 additions & 0 deletions src/agents/pi-tools.before-tool-call.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { randomUUID } from "node:crypto";
import type { AnyAgentTool } from "./tools/common.js";
import { createInternalHookEvent, triggerInternalHook } from "../hooks/internal-hooks.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
import { getGlobalHookRunner } from "../plugins/hook-runner-global.js";
import { normalizeToolName } from "./tool-policy.js";
Expand Down Expand Up @@ -31,6 +32,17 @@ export async function runBeforeToolCallHook(args: {

const toolName = normalizeToolName(args.toolName || "tool");
const params = args.params;
const hookSessionKey = args.ctx?.sessionKey ?? `tool:${toolName}`;
try {
const hookEvent = createInternalHookEvent("agent", "tool:start", hookSessionKey, {
toolName,
toolCallId: args.toolCallId ?? args.ctx?.toolCallId,
params: isPlainObject(params) ? params : undefined,
});
await triggerInternalHook(hookEvent);
} catch (err) {
log.warn(`agent:tool:start hook failed: tool=${toolName} error=${String(err)}`);
}
try {
const normalizedParams = isPlainObject(params) ? params : {};
const hookResult = await hookRunner.runBeforeToolCall(
Expand Down Expand Up @@ -102,6 +114,20 @@ export async function runAfterToolCallHook(args: {
const toolCallId = args.toolCallId ? ` toolCallId=${args.toolCallId}` : "";
log.warn(`after_tool_call hook failed: tool=${toolName}${toolCallId} error=${String(err)}`);
}
const hookSessionKey = args.ctx?.sessionKey ?? `tool:${toolName}`;
try {
const hookEvent = createInternalHookEvent("agent", "tool:end", hookSessionKey, {
toolName,
toolCallId: args.toolCallId ?? args.ctx?.toolCallId,
params,
result: args.result,
error: args.error,
durationMs: args.durationMs,
});
await triggerInternalHook(hookEvent);
} catch (err) {
log.warn(`agent:tool:end hook failed: tool=${toolName} error=${String(err)}`);
}
}

export function wrapToolWithBeforeToolCallHook(
Expand Down