Add context event for non-destructive message modification before LLM calls
- Add contextTransform option to Agent (runs before messageTransformer) - Deep copy messages before passing to contextTransform (modifications are ephemeral) - Add ContextEvent and ContextEventResult types - Add emitContext() to HookRunner (chains multiple handlers) - Wire up in sdk.ts when creating Agent with hooks Enables dynamic context pruning: hooks can modify messages sent to LLM without changing session data. See discussion #330.
This commit is contained in:
@@ -227,7 +227,7 @@ interface HookUIContext {
|
||||
|
||||
See also: `CustomEntry<T>` for storing hook state that does NOT participate in context.
|
||||
|
||||
**New: `context` event (TODO)**
|
||||
**New: `context` event ✅**
|
||||
|
||||
Fires before messages are sent to the LLM, allowing hooks to modify context non-destructively.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user