Skip to content

cleanAgentState drops foreman, modelSpawnKey and workspaceId on every state.json write #4487

Description

@eltmon

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions