Clear stale subagent lineage on top-level sessions#67946
Conversation
Greptile SummaryThis PR fixes issue #67943 by preventing regular top-level sessions from inheriting stale subagent lineage metadata ( Confidence Score: 5/5Safe to merge — targeted fix with a clear regression test and no collateral risk. All three changed files are narrowly scoped: the production changes gate stale lineage fields behind a well-tested predicate, the test converts a static mock to a spy and adds a regression case that directly covers the bug scenario. No P0/P1 findings. No files require special attention. Reviews (1): Last reviewed commit: "clear stale subagent lineage on top-leve..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f772863cb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Good catch. I narrowed the cleanup so it only clears stale subagent lineage fields, while preserving for normal thread sessions that have already forked from their parent. Re-pushed. |
|
CI is green now, this is ready to merge. ✅ |
|
Codex review: needs maintainer review before merge. Reviewed July 3, 2026, 3:08 AM ET / 07:08 UTC. Summary PR surface: Source +16, Tests +28. Total +44 across 3 files. Reproducibility: yes. from source inspection: seed a normal top-level session entry with stale Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land a clean rebased version of the subagent/ACP lineage gate that preserves parent/fork metadata, with final-head proof and focused regression coverage. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: seed a normal top-level session entry with stale Is this the best way to solve the issue? Yes in shape: gating lineage preservation and fallback AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8ed6c78b7891. Label changesLabel justifications:
Evidence reviewedPR surface: Source +16, Tests +28. Total +44 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
f3d2367 to
9b21e1a
Compare
|
Resolved the review concerns. I rebuilt the branch on current I also dropped the unrelated changes called out in review:
The PR diff is now limited to the stale top-level spawn-lineage fix plus focused regression coverage in:
Validation run locally:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
9b21e1a to
d52d898
Compare
d52d898 to
08c526f
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
6b45ca9 to
a1cc7e7
Compare
|
ClawSweeper PR egg ✨ Hatched: 🌱 uncommon Velvet Merge Sprite Hatch commandComment Hatchability rules:
Rarity: 🌱 uncommon. What is this egg doing here?
|
a1cc7e7 to
99eb967
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
Nice implementation! I appreciate the clear commit messages and focused changes. |
Fixes #67943.
Summary
Prevents normal top-level sessions from inheriting stale subagent lineage metadata that can incorrectly trip
sessions_spawndepth limits.What changed
subagent:*andacp:*sessionssessionEntry.spawnedByfor normal top-level agent runsupstream/mainReal behavior proof
Behavior or issue addressed: A normal top-level session key (
agent:main:main) could carry stale stored subagent lineage (spawnedBy,spawnDepth,spawnedWorkspaceDir,subagentRole,subagentControlScope). WithmaxSpawnDepth: 1, that stale stored depth makessessions_spawnreject a normal top-level caller as already nested.Real environment tested: Local OpenClaw checkout for PR Clear stale subagent lineage on top-level sessions #67946 on Linux/Node 22, rebased onto current
origin/main, heada1cc7e7681ccdb488f9fa2bb1d78823995291d25.Exact steps or command run after this patch: Ran a redacted local runtime proof from the patched checkout. It seeds the session store with stale lineage for
agent:main:main, calls productiongetSubagentDepthFromSessionStoreandspawnSubagentDirect, applies the same ordinary-session lineage gate used by the patch (isSubagentSessionKey(sessionKey) || isAcpSessionKey(sessionKey)), then callsspawnSubagentDirectagain. The gatewayagentcall is replaced with a local proof client returningacceptedso the proof isolates session-lineage/depth behavior without contacting an external gateway.Evidence after fix: Copied terminal output from the after-fix command:
Observed result after fix: The top-level session key is not subagent/ACP-shaped, the stale lineage fields are cleared, depth resolution drops from
1to0, and the samesessions_spawnpath changes fromforbiddentoaccepted.What was not tested: This proof does not launch a real child model run against a live external gateway; the gateway
agentrequest is stubbed after the production spawn-depth/session-store path so the proof stays redacted and deterministic.Validation
git diff --checkpnpm run lint:plugins:no-extension-test-core-importsCI=true pnpm exec vitest run --config test/vitest/vitest.agents.config.ts src/agents/agent-command.live-model-switch.test.tsTest Files 1 passed (1)Tests 20 passed (20)pnpm check:test-typesNote: targeted
pnpm exec oxlinton touched files still reports the pre-existing exported test helper name__testinginsrc/agents/agent-command.ts, so I did not count that as a passing validation gate.