Repository navigation
fix(bootstrap): inject app_profile on the first turn of a new app session - #71
Merged
Merged
Conversation
…sion resolveAppUserId reads appUserId from the persisted session entry, but chat.send only writes it onto an EXISTING entry (updateSessionStoreEntry no-ops when the entry is missing). On the first turn of a brand-new session the entry doesn't exist yet, so the id isn't available and the APP_PROFILE.md injection no-ops — the agent asks the user their name even though we know it. Every new app conversation (e.g. a page refresh / new chat) starts a fresh session and hit this; from turn 2 on the entry exists and the profile injects correctly. Fix: add appUserIdFromSessionKey() as a fallback. When the persisted entry has no appUserId yet, derive it from the session key itself — the second-to-last ":"-segment after ":app:", valid for both the namespaced 4-part form (app:havaya:<userId>:<conv>) and the legacy 3-part form (app:<userId>:<conv>), since the conversationId is always the final colon-free segment. Read-only and same-user (the id comes from this very session's key) — it cannot surface another user's profile, and it leaves the shared resolveAppUserId (and thus the workspace jail + save_user_section) untouched. Also brace the guard-returns in this file to satisfy oxlint `curly` — it was the only file with project lint errors (pre-existing from #68's --admin merge), so this greens `pnpm lint` repo-wide. Tests: appUserIdFromSessionKey unit cases (4-part / 3-part / bare / lowercasing / non-app / no-userId / undefined) + a first-turn fallback integration test (temp users/<id>.md, no persisted entry). vitest 22/22, lint 0, format clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cryptolir
added a commit
that referenced
this pull request
Jun 17, 2026
) (#73) STATUS.md: append the #71 first-turn fix + v2026.06.17.2 roll to the 2026-06-17 entry, with prod verification (fresh-session "Hi" now greets by name). INFRASTRUCTURE.md: bump the life-ahead drift note to v2026.06.17.2. Co-authored-by: Liran Peretz <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
cryptolir
pushed a commit
that referenced
this pull request
Jun 17, 2026
…v 2) Address the four findings + open-question answers on PR #72: - [P1] confine each load against the matched entry's own trusted root (baseDir), not a hardcoded <home>/skills/, so multi-root (bundled/managed) skills resolve. - [P1] tool allowlist = the same filtered, prompt-visible snapshot, not raw loadWorkspaceSkillEntries (no hidden-skill side channel). - [P2] gate on a resolved app user via the #71 resolveAppUserId ?? appUserIdFromSessionKey fallback (turn-1-safe); exclude _no-app-user. - [P2] drop the sibling files list from v1. Plus: trim+exact name match, 24KB cap with truncated flag, remove the dead life-access-scope carve-out and commit that hook to git, normal-session prompt snapshot regression test. Co-Authored-By: Claude Opus 4.8 <[email protected]>
cryptolir
added a commit
that referenced
this pull request
Jun 18, 2026
…oad_skill #74) (#75) Record the load_skill roll: #74 merged, gateway v2026.06.18.1 (sourceSha 09a99e4) pinned to life only — ships the full per-user stack to prod (writer #65/#66 + injection #68 + first-turn #71 + load_skill #74). Bump the INFRASTRUCTURE life-ahead tag to v2026.06.18.1 and note the US-host disk cleanup (97% to 67%, removed 8 unused/unreferenced gateway tags). Co-authored-by: Liran Peretz <[email protected]> Co-authored-by: Claude Opus 4.8 <[email protected]>
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.
Problem
New users — and anyone refreshing or starting a fresh chat — were greeted with "what's your name?" even though the per-user
app_profile(Phase 3, #68) holds their name. The profile injection worked from the second message onward, but never on the first.Root cause
appendAppProfileBootstrapFileresolves the user viaresolveAppUserId, which readsappUserIdfrom the persisted session entry.chat.sendwrites that id withupdateSessionStoreEntry, which no-ops when the entry doesn't exist yet (config/sessions/store.ts:if (!existing) return null). On the first turn of a brand-new session the entry doesn't exist, so the id isn't persisted until the run creates the entry — i.e. only from turn 2 onward. The first message therefore runs with noAPP_PROFILE.mdinjected.Reproduced on prod
life(v2026.06.17.1): turn 1 of a new session → "what's your name?"; turn 2 of the same session → "Yes, Liran, I remember you." The session store confirms it: single-turn app sessions haveappUserId=null, multi-turn ones have it set.Fix
Add
appUserIdFromSessionKey()as a fallback. When the persisted entry has noappUserIdyet, derive it from the session key — the second-to-last:-segment after:app:(valid for both the namespacedapp:havaya:<userId>:<conv>and legacyapp:<userId>:<conv>forms, since the conversationId is always the final colon-free segment). Read-only and same-user (the id comes from this very session's key), so it cannot surface another user's profile, and it leaves the sharedresolveAppUserId— and thus the workspace jail +save_user_section— untouched.Also braces the guard-returns in this file to satisfy oxlint
curly; it was the only file with project lint errors (pre-existing), sopnpm lintis now green repo-wide.Testing
appUserIdFromSessionKeyunit cases (4-part / 3-part / bare / lowercasing / non-app / no-userId / undefined)users/<id>.md, no persisted entry → injectsAPP_PROFILE.md)vitest22/22,pnpm lint0/0,oxfmtclean🤖 Generated with Claude Code