Skip to content

fix(sessions): include subagent metadata in json#83629

Open
YuanHanzhong wants to merge 1 commit into
openclaw:mainfrom
YuanHanzhong:fix/sessions-json-subagent-metadata
Open

fix(sessions): include subagent metadata in json#83629
YuanHanzhong wants to merge 1 commit into
openclaw:mainfrom
YuanHanzhong:fix/sessions-json-subagent-metadata

Conversation

@YuanHanzhong

@YuanHanzhong YuanHanzhong commented May 18, 2026

Copy link
Copy Markdown

Summary

  • add existing spawned-session lineage fields to sessions JSON rows
  • cover store-backed JSON output for spawned session metadata

Fixes #80286

Real behavior proof

  • Behavior or issue addressed: openclaw sessions --json now includes the stored spawned-session lineage fields instead of dropping them from the JSON projection.
  • Real environment tested: Local openclaw/openclaw checkout on macOS using the project Node.js test runner.
  • Exact steps or command run after this patch: Ran the focused sessions command regression with node scripts/run-vitest.mjs, then ran git diff --check.
  • Evidence after fix: Terminal capture from the focused command regression:
$ node scripts/run-vitest.mjs <focused sessions JSON regression>
✓ focused sessions command regression
15 passed
  • Observed result after fix: The JSON output regression passed and confirmed stored lineage fields are present in sessions JSON rows.
  • What was not tested: Full interactive terminal rendering was not tested; this patch only changes JSON row projection.

Testing

  • Focused sessions JSON regression command
  • git diff --check

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 18, 2026
@clawsweeper

clawsweeper Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Summary
The PR adds existing subagent lineage and lifecycle fields to openclaw sessions --json rows and covers the store-backed JSON projection with a focused command test.

Reproducibility: yes. Source inspection gives a high-confidence path: put a store row with spawnedBy or sessionFile behind openclaw sessions --store <path> --json, and current main reduces it through toSessionDisplayRow before JSON emission.

PR rating
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Summary: The implementation is small and source-reviewable, but test-only proof keeps the PR below merge-ready quality.

Rank-up moves:

  • Add redacted real CLI output showing a subagent JSON row with the new fields.
  • Confirm maintainer preference for default additive fields versus an opt-in flag.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

PR egg
🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature, rarity, or ASCII portrait is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

Real behavior proof
Needs real behavior proof before merge: The PR body provides only a focused test-run transcript, not redacted real openclaw sessions --store <path> --json output; the contributor should add terminal output, a terminal screenshot, logs, or a recording with private paths, endpoints, phone numbers, and keys redacted, then update the PR body for automatic re-review or ask a maintainer to comment @clawsweeper re-review.

Risk before merge
Why this matters: - The default CLI JSON row shape would gain optional path-bearing fields such as sessionFile and spawnedWorkspaceDir, which may affect strict JSON consumers or redacted-output sharing workflows.

  • The submitted proof is only a focused test-run transcript, not real CLI output from a sessions store containing subagent metadata.

Maintainer options:

  1. Prove and accept the additive JSON shape (recommended)
    Require a redacted real CLI JSON run showing a subagent row with the new fields, then merge if maintainers accept expanding the default response contract.
  2. Gate rich metadata behind an option
    If default JSON rows should avoid path and lineage expansion, revise the PR to add an explicit include flag and test both default and opted-in output.
  3. Pause for product direction
    Hold or close the PR if maintainers prefer a different supported lineage surface than openclaw sessions --json.

Next step before merge
Human review is needed because the remaining blockers are contributor real CLI proof and maintainer acceptance of the additive default JSON contract, not a narrow automated repair.

Security
Cleared: The diff only widens local CLI JSON projection and adds a focused test; it does not change dependencies, CI, install scripts, credentials handling, or code execution paths.

Review details

Best possible solution:

Merge the single projection-path fix after redacted real CLI output proves the fields and maintainers accept the additive default JSON shape, or switch to an explicit opt-in flag if they want the default row to stay thin.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection gives a high-confidence path: put a store row with spawnedBy or sessionFile behind openclaw sessions --store <path> --json, and current main reduces it through toSessionDisplayRow before JSON emission.

Is this the best way to solve the issue?

Yes, if maintainers accept the default JSON expansion. Adding the existing optional store fields to the single row adapter is the narrowest implementation; the safer alternative is an opt-in flag if path-bearing metadata should not appear by default.

Label justifications:

  • P2: This is a focused sessions CLI JSON improvement for subagent lineage consumers with limited blast radius.
  • merge-risk: 🚨 compatibility: The diff changes the default JSON row shape and may expose local path fields to strict consumers or shared command output.

What I checked:

  • Current main drops the requested fields before JSON output: toSessionDisplayRow currently projects only the thin display subset through contextTokens; fields such as spawnedBy, sessionFile, spawnedWorkspaceDir, status, label, and the interaction timestamps are not carried forward. (src/commands/sessions-table.ts:35, 13deea2a9d65)
  • JSON output reuses the reduced display row: sessionsCommand builds rows with toSessionDisplayRow, then spreads toJsonSessionRow(row) into the JSON payload, so any field omitted from the display row is absent from all CLI JSON output modes on current main. (src/commands/sessions.ts:358, 13deea2a9d65)
  • Store contract already has the requested metadata: SessionEntry already defines the requested source fields, including session file, spawn lineage, spawn depth/role/control scope, lifecycle timestamps, persisted run status, and label. (src/config/sessions/types.ts:198, 13deea2a9d65)
  • Linked issue is an implementation candidate, not a close reason: The PR body uses closing syntax for CLI sessions --json missing subagent runtime parent metadata (spawnedBy, label, status, sessionFile) #80286, whose body reports an active deployment with 44 store rows carrying spawnedBy and zero CLI JSON rows exposing it; the issue should remain open until a fix merges.
  • PR body proof is test-only: The current PR body provides a focused node scripts/run-vitest.mjs transcript and git diff --check, but no redacted real openclaw sessions --store <path> --json or openclaw sessions --agent <agent> --json output showing the new fields. (ab3c33615477)
  • Feature history for the projection path: Blame and log tie the current sessions command projection and extracted table adapter to recent sessions work in commit 25aa72e, with adjacent sessions command and lineage work in earlier commits. (src/commands/sessions-table.ts:35, 25aa72edbd9f)

Likely related people:

  • Peter Steinberger: Current blame attributes the sessions CLI projection, extracted sessions table adapter, and current SessionEntry shape in this checkout to recent sessions work in 25aa72e. (role: recent area contributor; confidence: medium; commits: 25aa72edbd9f, 4ee41cc6f31e, 3efd224ec63d; files: src/commands/sessions.ts, src/commands/sessions-table.ts, src/config/sessions/types.ts)
  • Vincent Koc: Recent history includes command-path sessions work that trimmed sessions cold-path imports, making this a relevant routing candidate for CLI sessions projection concerns. (role: adjacent command-path contributor; confidence: medium; commits: ed1dfe23d473; files: src/commands/sessions.ts, src/commands/sessions-table.ts)
  • xaeon2026: The ACP sessions patch lineage commit added support for spawnedBy and spawnDepth lineage fields in the Gateway patch path, adjacent to the metadata this PR exposes through CLI JSON. (role: adjacent lineage contributor; confidence: medium; commits: 425bd89b48dd; files: src/gateway/sessions-patch.ts, src/gateway/sessions-patch.test.ts)
  • Ayaan Zaidi: Recent session metadata history includes preserving CLI session metadata before transcript persistence, adjacent to the stored metadata contract this PR projects. (role: session metadata contributor; confidence: low; commits: 898fd0482a40; files: src/agents/agent-command.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 13deea2a9d65.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant