Function
executePostSamplingHooks
(
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 | */ |
| 45 | export 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 | } |
Tested by
no test coverage detected