MCPcopy Create free account
hub / github.com/freecodexyz/free-code / executePostSamplingHooks

Function executePostSamplingHooks

src/utils/hooks/postSamplingHooks.ts:45–70  ·  view source on GitHub ↗
(
  messages: Message[],
  systemPrompt: SystemPrompt,
  userContext: { [k: string]: string },
  systemContext: { [k: string]: string },
  toolUseContext: ToolUseContext,
  querySource?: QuerySource,
)

Source from the content-addressed store, hash-verified

43 * Execute all registered post-sampling hooks
44 */
45export async function executePostSamplingHooks(
46 messages: Message[],
47 systemPrompt: SystemPrompt,
48 userContext: { [k: string]: string },
49 systemContext: { [k: string]: string },
50 toolUseContext: ToolUseContext,
51 querySource?: QuerySource,
52): Promise<void> {
53 const context: REPLHookContext = {
54 messages,
55 systemPrompt,
56 userContext,
57 systemContext,
58 toolUseContext,
59 querySource,
60 }
61
62 for (const hook of postSamplingHooks) {
63 try {
64 await hook(context)
65 } catch (error) {
66 // Log but don't fail on hook errors
67 logError(toError(error))
68 }
69 }
70}

Callers 1

queryLoopFunction · 0.85

Calls 2

toErrorFunction · 0.85
logErrorFunction · 0.50

Tested by

no test coverage detected