Problem
cleanAgentState in src/lib/agents/agent-state-read.ts (grep export function cleanAgentState) is the whitelist every state.json read and write goes through: writeAgentStateJson in src/lib/agents/agent-state.ts serializes cleanAgentState(state), and parseAgentState returns cleanAgentState(...).
The whitelist omits three fields that AgentState declares and that spawn.ts writes into the spawn state literal:
foreman (spawn.ts, role, foreman: options.foreman || undefined, in both spawnRun and spawnAgent)
modelSpawnKey (PAN-2053; read by src/dashboard/server/services/model-origin-enrich.ts, which then silently falls back to ${role}:${issueId})
workspaceId (PAN-1990)
So these values never reach disk. The MODEL inspector's "exact" spawn key is always the fallback, and foreman is lost on the first save.
Fix
Add the three fields to cleanAgentState. Add a round-trip test: saveAgentStateSync(state) then getAgentState(id) keeps foreman, modelSpawnKey, and workspaceId.
Found while planning PAN-4253, which adds effort/effortSource to the same whitelist.
Problem
cleanAgentStateinsrc/lib/agents/agent-state-read.ts(grepexport function cleanAgentState) is the whitelist everystate.jsonread and write goes through:writeAgentStateJsoninsrc/lib/agents/agent-state.tsserializescleanAgentState(state), andparseAgentStatereturnscleanAgentState(...).The whitelist omits three fields that
AgentStatedeclares and thatspawn.tswrites into the spawn state literal:foreman(spawn.ts,role, foreman: options.foreman || undefined,in bothspawnRunandspawnAgent)modelSpawnKey(PAN-2053; read bysrc/dashboard/server/services/model-origin-enrich.ts, which then silently falls back to${role}:${issueId})workspaceId(PAN-1990)So these values never reach disk. The MODEL inspector's "exact" spawn key is always the fallback, and
foremanis lost on the first save.Fix
Add the three fields to
cleanAgentState. Add a round-trip test:saveAgentStateSync(state)thengetAgentState(id)keepsforeman,modelSpawnKey, andworkspaceId.Found while planning PAN-4253, which adds
effort/effortSourceto the same whitelist.