Skip to content

CLI sessions --json missing subagent runtime parent metadata (spawnedBy, label, status, sessionFile) #80286

@islandpreneur007

Description

@islandpreneur007

Summary

openclaw sessions --agent <agent> --json does not expose spawnedBy, label, status, or sessionFile fields that are present in the underlying Gateway session store (sessions.json). This blocks consumers that need to reason about subagent runtime parent lineage from the supported CLI surface.

Reproduction

In an OpenClaw deployment with at least one agent that has spawned subagents:

# CLI JSON projection (current)
openclaw sessions --agent <agent> --json \
  | jq '.sessions[] | select(.key | contains("subagent")) | keys' \
  | head -1

Returned keys are limited to a thin subset (e.g. key, sessionId, updatedAt, ageMs, agentId, agentRuntime, inputTokens, outputTokens, model, modelProvider, contextTokens, kind). spawnedBy, label, status, sessionFile, sessionStartedAt, lastInteractionAt are absent.

# Underlying store (source of truth)
jq '.[] | select(.spawnedBy != null) | keys' \
  ~/.openclaw/agents/<agent>/sessions/sessions.json \
  | head -1

The store row contains the rich runtime parent metadata. The same is true through --store <path> --json and --store --verbose --json — the projection is consistent across all documented openclaw sessions flag combinations.

We confirmed this empirically against an active deployment: 44 subagent rows total, 44 with spawnedBy present in sessions.json, 0 with spawnedBy exposed via CLI JSON.

Why this matters

Read-only consumers (lineage detectors, governance audits, fleet observability) that follow substrate-discipline (CLI as authoritative interface, no direct store reads) currently cannot:

  • Distinguish "runtime lineage known but task lineage missing" from "runtime lineage unknown"
  • Compute runtimeLineageCoveragePct accurately
  • Avoid overstating unknown-lineage debt when the runtime in fact has the metadata

We are working around this by emitting sourceShapeStatus="blocked_no_rich_source" and honest zero-coverage counters until a supported surface exposes the fields.

Requested fields on openclaw sessions ... --json

Make these additive (optional) on the existing JSON projection:

Field Type Notes
spawnedBy string? Parent session key
label string? Human-readable subagent label
status string? Session lifecycle status (live, done, aborted, ...)
sessionFile string? Transcript path
sessionStartedAt number? ms epoch
lastInteractionAt number? ms epoch
subagentRole string? leaf / branch / root
subagentControlScope string? none / limited / full
spawnedWorkspaceDir string? Workspace at spawn

Backward compatibility: existing fields unchanged, all new fields optional, omitted when absent in store.

Possible shapes

Option A — extend default projection. Map the Gateway-side fields directly onto the CLI JSON output. Single source, minimal churn for consumers, slight output-size increase.

Option B — opt-in flag. New --include-parent-metadata (or similar) that gates the rich projection. Avoids any output-size impact for current consumers.

Either works for our use case.

Acceptance

  • openclaw sessions --agent <agent> --json returns spawnedBy for every subagent row whose store entry has it.
  • openclaw sessions --store <path> --json returns the same fields when reading a store path directly.
  • Existing CLI JSON consumers continue to parse the output without change.

Docs reference

docs/cli/sessions.md notes that the CLI returns minimal row fields by default; the request here is to make subagent runtime parent metadata reachable via the supported CLI surface so consumers don't have to choose between losing the data and reading the persisted store directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions