Agent identity profile's agent_model is frozen at first-ever provisioning, never updates
Background
Noticed a real discrepancy: https://staging.musehub.ai/gabriel/mists/4dB2qCpPV5vG's
provenance correctly shows model_id: "claude-sonnet-5" (accurate, per-object,
live), but the linked claude-code agent profile
(https://staging.musehub.ai/claude-code) shows model claude-sonnet-4-6 — an
older model, from before this session's convention shifted to claude-sonnet-5.
Root cause, traced precisely — not assumed
Two contributing bugs:
ensure_agent_identity(musehub/services/derived_agent_provisioner.py:40-45) is a pure upsert:existing = (await session.execute( select(MusehubIdentity).where(MusehubIdentity.handle == handle) )).scalar_one_or_none() if existing is not None: return existingOnce an agent's
musehub_identitiesrow exists,agent_modelis never updated again — regardless of how many later commits use a different model. Every subsequent profile view returns the same frozen row.The seed value itself came from the wrong commit. The fallback lookup that seeds
agent_modelwhen first auto-provisioning a derived agent (musehub/api/routes/musehub/ui_user_profile.py:122-130) orders byMusehubCommit.timestampascending,.limit(1)— the oldest commit by thatagent_id, not the most recent:select(MusehubCommit.agent_id, MusehubCommit.model_id, MusehubCommit.timestamp) .where(MusehubCommit.agent_id == handle) .order_by(MusehubCommit.timestamp) # ascending — oldest first .limit(1)So
claude-code's identity got permanently seeded with whatever model was used in its very first-ever commit, and has been frozen there since.
Worth noting: musehub/api/routes/musehub/ui_agents.py:278-297 (a different
agent-profile-adjacent route, repo-scoped) does this correctly — orders by
MusehubCommit.timestamp.desc() and re-derives model_id on every request
rather than caching it. That's the pattern to converge on.
Goal (to be decided when picked up — this is a placeholder with real findings, not a full plan yet)
Decide deliberately: should agent_model mean "the model this identity was
first seen using" (a genesis/historical marker, in which case the bug is only
#1 — the oldest-first ordering was actually intentional and just needs the
value to stay frozen, which it already does) or "the model this identity is
currently using" (in which case both bugs need fixing: reseed from the
newest commit, and refresh on every new commit rather than caching forever)?
Given the profile page reads as a live status indicator (no "since" or
"first seen" qualifier next to it), current behavior is almost certainly the
wrong interpretation for how it's displayed today.
Out of Scope (for now)
- Any broader redesign of derived-agent auto-provisioning beyond this one field.
- Retroactively backfilling
agent_modelfor already-provisioned identities — decide whether that's needed once the live-vs-genesis question is resolved.