feat(plugins): pass sender_id to pre_llm_call hook

The pre_llm_call plugin hook receives session_id, user_message,
conversation_history, is_first_turn, model, and platform — but not
the sender's user_id. This means plugins cannot perform per-user
access control (e.g. restricting knowledge base recall to authorized
users).

The gateway already passes source.user_id as user_id to AIAgent,
which stores it in self._user_id. This change forwards it as
sender_id in the pre_llm_call kwargs so plugins can use it for
ACL decisions.

For CLI sessions where no user_id exists, sender_id defaults to
empty string. Plugins can treat empty sender_id as a trusted local
call (the owner is at the terminal) or deny it depending on their
ACL policy.
This commit is contained in:
Moris Chao 2026-04-10 11:02:23 +08:00 committed by Teknium
parent caf371da18
commit 5b16f31702

View file

@ -7629,6 +7629,7 @@ class AIAgent:
is_first_turn=(not bool(conversation_history)),
model=self.model,
platform=getattr(self, "platform", None) or "",
sender_id=getattr(self, "_user_id", None) or "",
)
_ctx_parts: list[str] = []
for r in _pre_results: