🔧 update: inject sender userId into LLM context so owner is correctly identified via web dashboard#84
Open
Copilot wants to merge 3 commits into
Open
🔧 update: inject sender userId into LLM context so owner is correctly identified via web dashboard#84Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
…ntity Agent-Logs-Url: https://github.com/warengonzaga/tinyclaw/sessions/86909675-1107-446e-8ee8-abb371b60b2c Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
warengonzaga
May 20, 2026 11:52
View session
There was a problem hiding this comment.
Pull request overview
Updates the core agent loop prompt construction to explicitly provide the LLM with the current sender’s userId, so owner-vs-friend authority rules can be applied correctly when chatting via the web dashboard.
Changes:
- Adds a
systemmessage marker ([Current message sender: userId = ...]) immediately before the incomingusermessage in the LLM message array. - Documents the rationale inline to reduce future regressions around owner identification.
Agent-Logs-Url: https://github.com/warengonzaga/tinyclaw/sessions/0fae7cf1-eeeb-4e1c-8a9f-f108bd1776c1 Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
… tests Agent-Logs-Url: https://github.com/warengonzaga/tinyclaw/sessions/0fae7cf1-eeeb-4e1c-8a9f-f108bd1776c1 Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the owner interacts through the web dashboard, the LLM was misidentifying them as a "friend" and refusing owner-only actions (e.g., changing the companion's name). The system prompt declared
cli:owneras the owner userId, but no userId was ever passed alongside incoming messages — leaving the LLM to guess, and incorrectly infer that a web session couldn't becli:owner.Change
packages/core/src/loop.tssanitizeUserIdForPrompt()to strip backticks, square brackets, and newlines fromuserIdbefore embedding it in any prompt, preventing a crafteduserIdfrom breaking the marker format or injecting additional instructions.systemmessage immediately before the user message. This ensures the identity covers the entire turn — including all tool-follow-up user messages — without needing per-message injection.packages/core/tests/loop.test.ts[Current message sender: userId = ...]marker is present in the system prompt content and that the immediately following message is the user turn (no separate system entry in between).at(-2)/at(-1)assertions remain correct and unchanged.The
userIdpassed here is resolved server-side fromconfigManager.get('owner.ownerId'), so the LLM now has a ground-truth sender identity to match against theownerIdin the system prompt — regardless of which channel the message arrived through.