|
Entropic 2.3.8
Local-first agentic inference engine
|
Hook point enum and callback types for engine lifecycle hooks. More...
#include <stddef.h>

Go to the source code of this file.
Typedefs | |
| typedef int(* | entropic_hook_callback_t) (entropic_hook_point_t hook_point, const char *context_json, char **modified_json, void *user_data) |
| Hook callback function type. | |
Hook point enum and callback types for engine lifecycle hooks.
Consumers register callbacks at hook points to intercept, modify, inspect, and transform engine behavior without forking. Pre-hooks can modify context or cancel operations. Post-hooks can transform results. Failing hooks are logged and skipped — never crash the engine.
Definition in file hooks.h.
| typedef int(* entropic_hook_callback_t) (entropic_hook_point_t hook_point, const char *context_json, char **modified_json, void *user_data) |
Hook callback function type.
Pre-hook semantics:
Post-hook semantics:
For POST_TOOL_CALL specifically (since v2.1.1, issue #2): the engine treats *modified_json as the replacement string for the tool result's Message::content — NOT as a JSON context object to be deconstructed. Mirrors POST_GENERATE's "raw text in / raw text out" semantic. Hook authors wanting to inspect the structured pre-hook context (tool_name, args, raw result, directives, result_kind) read those from the input context_json; the output is just the replacement content. When multiple POST_TOOL_CALL hooks are registered, last-write-wins per registry semantics — each hook receives the same context_json; the final *modified_json (whichever hook wrote it last) is what the engine applies. Pre-2.1.1 the engine called free() on *modified_json without applying the transform — silently breaking redaction/enrichment/normalization hooks.
The engine frees *modified_json after consuming it. The callback MUST allocate it with entropic_alloc() (not malloc, not new, not stack).
| hook_point | Which hook point fired. |
| context_json | JSON string with hook-specific context data. Owned by the engine, valid only for this call. |
| modified_json | Output: replacement JSON, or NULL for no change. Allocated by callback with entropic_alloc(), freed by engine. |
| user_data | Opaque pointer from registration. |
@callback
Hook points in the engine lifecycle.
Each value identifies a stage where registered callbacks are invoked. Pre-hooks can cancel the operation by returning non-zero. Post-hooks can transform results via the modified_json out-param. Informational hooks fire for observation only.
New values are appended only — no renumbering (ABI stable).