mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-29 16:54:30 +00:00
feat(plugins): add modelOverride/providerOverride to before_agent_start hook
Enable plugins to override the model and provider for agent runs by returning modelOverride/providerOverride from the before_agent_start hook. The hook is now invoked early in run.ts (before resolveModel) so overrides take effect. The result is passed to attempt.ts via earlyHookResult to prevent double-firing. This enables security-critical use cases like routing PII-containing prompts to local models instead of cloud providers.
This commit is contained in:
committed by
Peter Steinberger
parent
15dd2cda20
commit
b90eb51520
@@ -200,6 +200,8 @@ export function createHookRunner(registry: PluginRegistry, options: HookRunnerOp
|
||||
acc?.prependContext && next.prependContext
|
||||
? `${acc.prependContext}\n\n${next.prependContext}`
|
||||
: (next.prependContext ?? acc?.prependContext),
|
||||
modelOverride: next.modelOverride ?? acc?.modelOverride,
|
||||
providerOverride: next.providerOverride ?? acc?.providerOverride,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -332,6 +332,10 @@ export type PluginHookBeforeAgentStartEvent = {
|
||||
export type PluginHookBeforeAgentStartResult = {
|
||||
systemPrompt?: string;
|
||||
prependContext?: string;
|
||||
/** Override the model for this agent run. E.g. "llama3.3:8b" */
|
||||
modelOverride?: string;
|
||||
/** Override the provider for this agent run. E.g. "ollama" */
|
||||
providerOverride?: string;
|
||||
};
|
||||
|
||||
// llm_input hook
|
||||
|
||||
Reference in New Issue
Block a user