Skip to content

fix: persona is source of truth at spawn + thread-depth conventions#930

Merged
wesbillman merged 3 commits into
mainfrom
brain/thread-conventions
Jun 9, 2026
Merged

fix: persona is source of truth at spawn + thread-depth conventions#930
wesbillman merged 3 commits into
mainfrom
brain/thread-conventions

Conversation

@wesbillman

@wesbillman wesbillman commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

What

Two related changes that came out of improving thread behavior:

  1. Runtime fix — persona is the source of truth at spawn.
    Persona edits never reached agents created from a plain persona (not an installed pack). Spawn only consulted the live PersonaRecord when both persona_pack_path and persona_name_in_pack were set, so non-pack agents fell through to the frozen record.system_prompt snapshot. Editing the persona left that snapshot stale — no restart could pick it up.

    The fix drops the has_persona_pack gate: the linked persona is resolved whenever persona_id is set (pack or not). Falls back to the record snapshot only when no persona is linked or it was deleted. Pack agents are unaffected (they already set persona_id).

    Logic is extracted into a pure resolve_effective_prompt_and_model() helper; the runtime test module moved to runtime/tests.rs (the existing env_vars/tests.rs pattern), which keeps runtime.rs under the file-size limit.

  2. Docs — sharpen thread-depth & root-reporting conventions in base_prompt.md so the guidance is shared with every agent on next session.

Design decision: persona always wins

For persona-linked agents the persona prompt is authoritative; per-agent Edit-Agent prompt overrides are intentionally a no-op for them. This is what keeps the fix to ~1 file. Per-agent tweaks, if ever wanted, are a separate clean feature.

Supersedes #729

#729 fixed the same bug but chose to preserve per-agent overrides, which required a new precedence model + a startup migration + provider-deploy wiring across 6 files, and was closed. This is the smaller persona-always-wins version.

Verification

  • cargo test --lib → 456 passed, 0 failed (4 new tests: persona-wins, no-persona fallback, deleted-persona fallback, persona-clears-stale-model)
  • cargo fmt --check, cargo clippy --lib (no warnings), cargo check --all-targets, file-size check — all clean

@wesbillman wesbillman requested a review from a team as a code owner June 9, 2026 19:28
@wesbillman wesbillman changed the title docs(prompt): proposed thread-depth & root-reporting conventions fix: persona is source of truth at spawn + thread-depth conventions Jun 9, 2026
wesbillman and others added 2 commits June 9, 2026 17:22
Tighten the base prompt's threading guidance so agents keep threads shallow
(reply to the thread root, not the latest message) and surface milestones at
the channel root. Folds the existing "broadcast on completion" bullet into the
new "report milestones at the root" bullet to avoid restating the same idea.

Proposed convention for team discussion — not a unilateral default change.

Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
…ents

Persona edits never reached agents created from a plain persona (not an
installed pack): spawn only consulted the live PersonaRecord when both
persona_pack_path and persona_name_in_pack were set, so non-pack agents
fell through to the frozen record.system_prompt snapshot. Editing the
persona left that snapshot stale, and no restart could pick it up.

Resolve the linked persona whenever persona_id is set (pack or not); the
persona is the source of truth and edits propagate on the next spawn.
Fall back to the record snapshot only when no persona is linked or it was
deleted. Pack agents are unaffected (they already set persona_id).

Extract the resolution into a pure helper and move the runtime test module
to runtime/tests.rs (env_vars/tests.rs pattern), keeping runtime.rs under
the file-size limit. 4 new unit tests cover persona-wins, no-persona
fallback, deleted-persona fallback, and persona-clears-stale-model.

Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
@wesbillman wesbillman force-pushed the brain/thread-conventions branch from f572373 to 3ba2072 Compare June 9, 2026 23:27
Pack edits on disk were not propagating to persona records until the
user manually uninstalled and reimported. This left the spawn-time
persona resolution (fixed in this branch) reading stale data for pack
agents.

On startup, iterate persona records with source_pack set, resolve the
corresponding pack directory, and update system_prompt, model,
avatar_url, and display_name if they differ from the resolved pack
content.

Signed-off-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
@wpfleger96 wpfleger96 force-pushed the brain/thread-conventions branch from eb15be0 to 48698b2 Compare June 9, 2026 23:47
@wesbillman wesbillman enabled auto-merge (squash) June 9, 2026 23:50
@wesbillman wesbillman merged commit 877048d into main Jun 9, 2026
16 checks passed
@wesbillman wesbillman deleted the brain/thread-conventions branch June 9, 2026 23:58
tlongwell-block pushed a commit that referenced this pull request Jun 10, 2026
* origin/main:
  Fix post-compact handoff context for OpenAI providers (#931)
  chore(release): release version 0.3.15 (#936)
  fix: persona is source of truth at spawn + thread-depth conventions (#930)
  fix: skip avatar reconciliation for legacy agent records (#933)
  feat(desktop): add nest commit identity guidance with human sign-off (#929)
  feat: provider/model selection for personas and runtime-aware env injection (#794)
  fix: reconcile agent profile on startup when relay publish was missed (#921)
  Revamp first-run onboarding (#924)
  Update setup loading screen (#926)
  fix(dm): keep hidden DMs hidden across refetch via relay-signed visibility snapshot (NIP-DV) (#857)
  Maximize desktop window on launch (#925)
  feat: preview features (experiments settings UI) (#888)
  fix(updater): send no-cache header on update check to avoid stale manifest (#922)
  fix(desktop): refresh channel state after unarchive (#923)
  Add channel visibility & ephemeral TTL controls to manage sidebar (#911)
  ci(release): add Intel macOS (x86_64) DMG as a release target (#748)

Signed-off-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co>

# Conflicts:
#	desktop/src/features/sidebar/ui/AppSidebar.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants