mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 14:02:51 +00:00
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:
parent
9e165d1d81
commit
77fe3f1a13
6 changed files with 89 additions and 2 deletions
|
|
@ -589,6 +589,11 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|||
tools: allToolsArray,
|
||||
},
|
||||
messageTransformer,
|
||||
contextTransform: hookRunner
|
||||
? async (messages) => {
|
||||
return hookRunner.emitContext(messages);
|
||||
}
|
||||
: undefined,
|
||||
queueMode: settingsManager.getQueueMode(),
|
||||
transport: new ProviderTransport({
|
||||
getApiKey: async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue