Skip to content

feat(desktop): re-snapshot persona config on every agent spawn#1268

Merged
wpfleger96 merged 2 commits into
mainfrom
duncan/persona-refresh-on-spawn
Jun 25, 2026
Merged

feat(desktop): re-snapshot persona config on every agent spawn#1268
wpfleger96 merged 2 commits into
mainfrom
duncan/persona-refresh-on-spawn

Conversation

@wpfleger96

Copy link
Copy Markdown
Collaborator

Summary

When an agent linked to a persona is spawned (or auto-restored on launch), the persona's current system_prompt, model, provider, env_vars, and persona_source_version hash are written back onto the agent record before the process starts. This clears the "OUT OF DATE" drift badge without requiring a delete+recreate cycle.

Changes

commands/agents.rs — In start_local_agent_with_preflight, before calling start_managed_agent_process, re-snapshot the persona onto the mutable record. After save_managed_agents, call retain_managed_agent_pending to queue a relay publish of the updated record.

managed_agents/restore.rs — In restore_managed_agents_on_launch Phase A, after building to_start, re-snapshot all persona-linked agents in that set. Set changed = true so the refreshed records are persisted. Re-collect to_start from the mutated records slice so Phase B spawns the refreshed config.

ManagedAgentRow.tsx — Update the "OUT OF DATE" badge tooltip to remove the now-stale instruction to delete the agent before respawning.

Behavior

  • Agent-level env_vars overrides still win — persona_snapshot layers persona env under agent overrides, matching the create-time contract.
  • Agents without a persona_id are unaffected.
  • If the linked persona is deleted, the agent spawns from its existing record fields (same fallback as before).

Acceptance Criteria

  • After editing a persona's system prompt and clicking Spawn on a linked agent, the agent starts with the new system prompt and the "OUT OF DATE" badge is gone
  • persona_source_version on the agent record matches the current persona hash after spawn
  • Auto-start agents pick up the current persona on app launch
  • cargo check passes clean

When an agent linked to a persona is spawned (or auto-restored on
launch), the persona's current system_prompt, model, provider, env_vars,
and source_version hash are written back onto the agent record before the
process starts. This clears the "OUT OF DATE" drift badge without
requiring a delete+recreate cycle.

Two spawn paths are covered:
- Interactive spawn (start_local_agent_with_preflight): re-snapshots
  before start_managed_agent_process and queues a relay publish via
  retain_managed_agent_pending so the updated record propagates.
- Auto-restore on launch (restore_managed_agents_on_launch Phase A):
  re-snapshots all agents in the to_start set before Phase B spawns
  them, and re-collects to_start from the mutated records so Phase B
  sees the refreshed config.

Agent-level env_vars overrides still win — persona_snapshot layers
persona env under agent overrides, matching the create-time contract.

Also updates the "OUT OF DATE" badge tooltip to remove the now-stale
instruction to delete the agent before respawning.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
@wpfleger96 wpfleger96 force-pushed the duncan/persona-refresh-on-spawn branch from 762011b to d56ce4e Compare June 25, 2026 03:12
Biome reformatted the warning text line break in ManagedAgentRow.tsx.
Bumped the agents.rs file-size override from 1350 to 1380 to account
for the ~23 lines added by the persona re-snapshot path.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
@wpfleger96 wpfleger96 merged commit 048e8fd into main Jun 25, 2026
25 checks passed
@wpfleger96 wpfleger96 deleted the duncan/persona-refresh-on-spawn branch June 25, 2026 03:32
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