Skip to content

feat(desktop): pin persona config to agent record at create#945

Merged
wpfleger96 merged 1 commit into
wpfleger/persona-eventsfrom
wpfleger/persona-instantiation
Jun 18, 2026
Merged

feat(desktop): pin persona config to agent record at create#945
wpfleger96 merged 1 commit into
wpfleger/persona-eventsfrom
wpfleger/persona-instantiation

Conversation

@wpfleger96

@wpfleger96 wpfleger96 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Persona-created agents previously re-read the live persona catalog at every spawn, so editing a persona template silently changed running agents on restart. This makes the agent record the authoritative source for spawn config: the persona's system_prompt, model, provider, and env_vars (plus its content hash) are snapshotted onto ManagedAgentRecord at create time, and the spawn and provider-deploy paths read that snapshot instead of the live catalog.

The result is the semantics Will specified:

  • Restart (stop + start) reuses the same record, so the agent stays pinned to the config it was created with.
  • Respawn (delete + recreate) re-runs create and rewrites the snapshot, picking up the edited persona.

env_vars are pinned alongside the other fields — without that, a persona credential edit (e.g. ANTHROPIC_API_KEY) would leak into a running agent on restart.

Spawn read-path

The shared resolve_effective_prompt_model_provider body is left intact — its build_managed_agent_summary and ModelPicker callers intentionally read the live persona. Only the spawn_agent_child and build_deploy_payload call sites move to the record snapshot. ModelPicker model-discovery stays live-read; it enumerates available models for the dropdown, not the running agent's config.

Drift indicator

build_managed_agent_summary compares the record's pinned persona_source_version against the linked persona's current persona_content_hash:

  • Out of date — the persona was edited since create. The Agents menu shows a marker and prompts the user to delete and respawn.
  • Orphaned — the linked persona no longer exists. Never flagged out-of-date, since there is nothing to respawn into.

The summary displays the pinned snapshot (what the agent actually runs), so the badge never contradicts the fields beside it.

Dead-code removal

With the record authoritative, the mem/persona engram and fleet-update subsystem became a self-referential write loop nothing read at spawn. Removed: fleet_update.rs, its launch and persona-save triggers, the engram-at-creation write, and the engram-only helpers in persona_events. The public persona catalog primitives (build_persona_event, persona_from_event, PersonaEventContent) from #939 are untouched — they remain the source the record snapshots from.

Migration

Pre-existing persona agents are backfilled from the live persona once at launch (before restore), logging loudly if the linked persona is gone so an agent never silently spawns from an empty snapshot.

Stack: #939 → this PR

@wpfleger96 wpfleger96 requested a review from a team as a code owner June 10, 2026 15:12
@wpfleger96 wpfleger96 force-pushed the wpfleger/persona-instantiation branch from b7475b7 to 45b0782 Compare June 10, 2026 15:13
@wpfleger96 wpfleger96 marked this pull request as draft June 10, 2026 16:27
wpfleger96 added a commit that referenced this pull request Jun 11, 2026
…Body

PersonaEventContent is the public struct serialized in kind:30175 events.
PR #939 removed env_vars from it (secrets must not travel in plaintext
events). This commit removes the re-addition from #945 and instead
carries env_vars in PersonaEngramBody, which is NIP-44 encrypted inside
the agent's mem/persona engram.

Co-authored-by: Will Pfleger <wpfleger@block.xyz>
Signed-off-by: Will Pfleger <wpfleger@block.xyz>
wpfleger96 added a commit that referenced this pull request Jun 11, 2026
…Body

PersonaEventContent is the public struct serialized in kind:30175 events.
PR #939 removed env_vars from it (secrets must not travel in plaintext
events). This commit removes the re-addition from #945 and instead
carries env_vars in PersonaEngramBody, which is NIP-44 encrypted inside
the agent's mem/persona engram.

Co-authored-by: Will Pfleger <wpfleger@block.xyz>
Signed-off-by: Will Pfleger <wpfleger@block.xyz>
@wpfleger96 wpfleger96 force-pushed the wpfleger/persona-instantiation branch from 4ef566d to aa4c16b Compare June 11, 2026 17:57
@wpfleger96 wpfleger96 force-pushed the wpfleger/persona-events branch from 817e596 to 5952ae5 Compare June 11, 2026 19:17
@wpfleger96 wpfleger96 force-pushed the wpfleger/persona-instantiation branch 3 times, most recently from adb48c0 to 82be04e Compare June 11, 2026 19:42
@wpfleger96 wpfleger96 force-pushed the wpfleger/persona-events branch from 9b8924a to 6c2e650 Compare June 12, 2026 18:45
@wpfleger96 wpfleger96 force-pushed the wpfleger/persona-instantiation branch from 82be04e to 0d573c2 Compare June 12, 2026 18:46
@wpfleger96 wpfleger96 changed the title feat(desktop): persona engram instantiation + fleet update + legacy sync gate feat(desktop): pin persona config to agent record at create Jun 17, 2026
@wpfleger96 wpfleger96 force-pushed the wpfleger/persona-instantiation branch 2 times, most recently from e3fd35e to e031707 Compare June 17, 2026 18:38
@wpfleger96 wpfleger96 force-pushed the wpfleger/persona-events branch 2 times, most recently from 289bfc2 to 2fb370f Compare June 17, 2026 20:28
@wpfleger96 wpfleger96 force-pushed the wpfleger/persona-instantiation branch 2 times, most recently from d750cce to 58f60d2 Compare June 17, 2026 21:06
@wpfleger96 wpfleger96 force-pushed the wpfleger/persona-events branch from e6a44d7 to 7c98207 Compare June 18, 2026 00:56
@wpfleger96 wpfleger96 force-pushed the wpfleger/persona-instantiation branch from 58f60d2 to 46d50c5 Compare June 18, 2026 00:56
Persona-created agents previously re-read the live persona catalog at
every spawn, so a template edit silently changed running agents on
restart. Snapshot the persona's system_prompt/model/provider/env_vars
plus its content hash onto ManagedAgentRecord at create, and switch the
spawn and provider-deploy call sites to read that snapshot. Restart
reuses the record so it stays pinned; delete+respawn re-runs create and
rewrites the snapshot. env_vars are pinned too — without that, persona
credential edits would leak into a running agent on restart.

The shared resolve_effective_prompt_model_provider body is left intact:
its summary and ModelPicker callers intentionally read the live persona,
so only the spawn/deploy call sites move to the snapshot.

The Agents menu gets a drift indicator: build_managed_agent_summary
compares the record's pinned source_version against the persona's
current hash. A deleted persona is orphaned (never out-of-date, since
there is nothing to respawn into). The summary now displays the pinned
snapshot — what the agent actually runs — so the badge never contradicts
the fields beside it.

The mem/persona engram and fleet-update subsystem are removed: with the
record authoritative, fleet-update became a self-referential write loop
nothing read at spawn. Deletes fleet_update.rs, its launch and
persona-save triggers, the engram-at-creation write, and the
engram-only helpers in persona_events. The public persona catalog
primitives (#939) are untouched — they remain the source the record
snapshots from. Pre-existing agents are backfilled from the live
persona once at launch, logging loudly if the linked persona is gone.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
@wpfleger96 wpfleger96 force-pushed the wpfleger/persona-instantiation branch from 46d50c5 to 72513e9 Compare June 18, 2026 01:04
@wpfleger96 wpfleger96 marked this pull request as ready for review June 18, 2026 01:36
@wpfleger96 wpfleger96 merged commit a47bb15 into wpfleger/persona-events Jun 18, 2026
26 checks passed
@wpfleger96 wpfleger96 deleted the wpfleger/persona-instantiation branch June 18, 2026 01:36
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.

1 participant