Repository navigation
fix(cron): attribute run messages to the automation - #150553
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 17, 2026, 9:00 AM ET / 13:00 UTC (Revision 2). ClawSweeper reviewWhat this changesRecords structured automation provenance and displays current automation names with clock icons and source-run links in chat. Merge readiness✅ Ready for maintainer review This PR remains useful: current main and the latest release lack the requested automation attribution. No actionable introduced defect was found, and the verified test merge resolves the earlier conflict blocker. Priority: P2 Review scores
Verification
How this fits togetherCron runs record prompts in session transcripts. Gateway history converts those records into display messages, and the Control UI renders their attribution separately from agent replies. flowchart LR
A[Scheduled automation] --> B[Transcript recorder]
B --> C[Stored prompt and provenance]
C --> D[Gateway display projection]
E[Current automation name] --> D
D --> F[Chat attribution and source link]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +198, Tests +578, Other -1. Total +775 across 40 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep automation identity producer-owned, resolve names in Gateway display projection, and preserve stored transcript bytes and the existing source-navigation contract. Do we have a high-confidence way to reproduce the issue? Yes, source establishes both paths: recorded cron prompts lack attribution metadata on main, and forwarded run messages fall back to unresolved session keys. No live reproduction was executed. Is this the best way to solve the issue? Yes, extending the existing transcript recorder and shared display projection is a coherent repair; the branch preserves historical unmarked text and keeps collapse behavior separately scoped. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f87c65300767. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
b37cced to
0c5fba7
Compare
0c5fba7 to
bf86130
Compare
|
Merged via squash.
|
…ld's reply (#162460) ## What Problem This Solves Fixes: a scheduled agent turn that only spawns a subagent and ends without text records its own prompt as the run summary, and announce jobs send that prompt to the chat instead of the subagent's reply. ## User Impact Spawn-only scheduled jobs again deliver and record the child's final reply. In our setup the delivered text was the job prompt plus the scheduler preamble ("This is an unattended scheduled run…"). ## Why This Change Was Made When a spawn-only run still has a running child at delivery time, cron waits for the child and then reads the run session's latest assistant reply through `chat.history` (the synthesis grace read from #39089), falling back to the child's own reply when the parent wrote nothing new. #150553 started projecting cron run prompts in `chat.history` as forwarded assistant rows (role `assistant`, input provenance `internal_system` / `sourceTool: "cron"`), the same presentation sessions_send messages already had. `readLatestAssistantReply` already skips the sessions_send projection by its `inter_session` provenance (#97259), but not the new cron one. So the grace read returned the prompt as if the parent had written it, and the child fallback never ran. The cron parent gets no completion wake turn in this shape (the scenario asserts exactly two parent provider requests), so the projected prompt was the only "reply" the read could find. The reader now skips both projected input kinds. Model replies never carry `inter_session` or `internal_system` provenance, so no real reply is skipped. All `readLatestAssistantReply` callers get the fix, including the child-session reads in the same flow. Hermes Agent sidesteps this class of bug: its cron takes the agent run's own final response and runs delegated work inline, so it never re-reads display history. OpenClaw spawns are asynchronous and settle after the parent turn, so the reader stays. It just has to ignore rows that are inputs. ## Evidence - Real flow, isolated Gateway with qa-lab mock-openai, `qa/scenarios/scheduling/cron-isolated-spawn-only-child-delivery.yaml`: - before (origin/main reader): fails. The run summary and the delivered text are the cron prompt: `"Subagent direct fallback QA check: spawn one native subagent worker. … This is an unattended scheduled run. …"`. - after: passes. Both cases (empty parent, heartbeat parent) deliver `QA-SUBAGENT-DIRECT-FALLBACK-OK` exactly once, record it as the summary, and retire the one-shot job. - A temporary dump of the run session's `chat.history` at the grace read showed the culprit: the first row was `role: "assistant"` carrying the prompt with `provenance: { kind: "internal_system", sourceTool: "cron", jobId, runId }`. Removed after diagnosis. - The scenario was failing on main for an unrelated fixture reason: with tool search on, the mock reached `sessions_yield` through `tool_call` although the job only allows `sessions_spawn` and `read`, so the parent was stopped as a blocked tool loop before delivery ran. The scenario now sets `tools.toolSearch: false`, which restores the path it was written for (#117308, #118743). - `src/agents/run-wait.test.ts`: the projected cron run prompt case fails before, passes after (64 tests; the new case runs in about 10 ms). `subagent-followup`, `delivery-dispatch.double-announce` and `hosted-lifecycle-dispatch` tests pass (196 total). - Telegram Test Server, real-user recorder (`telegram-e2e-userbot`, `--backend qa-mock --dm`, `tools.toolSearch: false`): one isolated announce cron job to the DM with the same empty-parent prompt and `--tools sessions_spawn,read`, run with `cron run --wait`. - before (origin/main build): run `ok`; the bot sent one DM message of 966 chars, starting `Subagent direct fallback QA check: spawn one native subagent worker. …` followed by the scheduler preamble (`This is an unattended scheduled run. …`). - after (this branch build): run `ok`; the bot sent one DM message, exactly `QA-SUBAGENT-DIRECT-FALLBACK-OK` (30 chars). - The recorder needed a `tools` field on its `cron` action to pass `--tools`; that harness tweak was local and is not part of this PR. - Live model, Telegram Test Server: same recorder, one isolated announce cron job to the DM, a live OpenAI model behind the provider slot (`tools.toolSearch: false`). The live parent chose `sessions_spawn` itself and the child answered live. Only the parent's turn after the accepted spawn was steered to end empty, because that is the spawn-only shape under test (a parent that writes text or `NO_REPLY` never reaches this read). - before (origin/main `600117c262b` build): run `ok`; the child answered `Titan.` live, but the bot sent one DM message of 957 chars: the cron prompt (`LIVE-SPAWN-ONLY check: call sessions_spawn exactly once …`) plus the scheduler preamble. - after (this head `eda6043d497` build): run `ok`; the child answered live and the bot sent one DM message, exactly the child's answer: `Titan is the largest moon of Saturn.` LOC vs origin/main: production +4/−1, tests +22/−7, QA scenario +4. Co-authored-by: Ayaan Zaidi <[email protected]>
…ld's reply (openclaw#162460) ## What Problem This Solves Fixes: a scheduled agent turn that only spawns a subagent and ends without text records its own prompt as the run summary, and announce jobs send that prompt to the chat instead of the subagent's reply. ## User Impact Spawn-only scheduled jobs again deliver and record the child's final reply. In our setup the delivered text was the job prompt plus the scheduler preamble ("This is an unattended scheduled run…"). ## Why This Change Was Made When a spawn-only run still has a running child at delivery time, cron waits for the child and then reads the run session's latest assistant reply through `chat.history` (the synthesis grace read from openclaw#39089), falling back to the child's own reply when the parent wrote nothing new. openclaw#150553 started projecting cron run prompts in `chat.history` as forwarded assistant rows (role `assistant`, input provenance `internal_system` / `sourceTool: "cron"`), the same presentation sessions_send messages already had. `readLatestAssistantReply` already skips the sessions_send projection by its `inter_session` provenance (openclaw#97259), but not the new cron one. So the grace read returned the prompt as if the parent had written it, and the child fallback never ran. The cron parent gets no completion wake turn in this shape (the scenario asserts exactly two parent provider requests), so the projected prompt was the only "reply" the read could find. The reader now skips both projected input kinds. Model replies never carry `inter_session` or `internal_system` provenance, so no real reply is skipped. All `readLatestAssistantReply` callers get the fix, including the child-session reads in the same flow. Hermes Agent sidesteps this class of bug: its cron takes the agent run's own final response and runs delegated work inline, so it never re-reads display history. OpenClaw spawns are asynchronous and settle after the parent turn, so the reader stays. It just has to ignore rows that are inputs. ## Evidence - Real flow, isolated Gateway with qa-lab mock-openai, `qa/scenarios/scheduling/cron-isolated-spawn-only-child-delivery.yaml`: - before (origin/main reader): fails. The run summary and the delivered text are the cron prompt: `"Subagent direct fallback QA check: spawn one native subagent worker. … This is an unattended scheduled run. …"`. - after: passes. Both cases (empty parent, heartbeat parent) deliver `QA-SUBAGENT-DIRECT-FALLBACK-OK` exactly once, record it as the summary, and retire the one-shot job. - A temporary dump of the run session's `chat.history` at the grace read showed the culprit: the first row was `role: "assistant"` carrying the prompt with `provenance: { kind: "internal_system", sourceTool: "cron", jobId, runId }`. Removed after diagnosis. - The scenario was failing on main for an unrelated fixture reason: with tool search on, the mock reached `sessions_yield` through `tool_call` although the job only allows `sessions_spawn` and `read`, so the parent was stopped as a blocked tool loop before delivery ran. The scenario now sets `tools.toolSearch: false`, which restores the path it was written for (openclaw#117308, openclaw#118743). - `src/agents/run-wait.test.ts`: the projected cron run prompt case fails before, passes after (64 tests; the new case runs in about 10 ms). `subagent-followup`, `delivery-dispatch.double-announce` and `hosted-lifecycle-dispatch` tests pass (196 total). - Telegram Test Server, real-user recorder (`telegram-e2e-userbot`, `--backend qa-mock --dm`, `tools.toolSearch: false`): one isolated announce cron job to the DM with the same empty-parent prompt and `--tools sessions_spawn,read`, run with `cron run --wait`. - before (origin/main build): run `ok`; the bot sent one DM message of 966 chars, starting `Subagent direct fallback QA check: spawn one native subagent worker. …` followed by the scheduler preamble (`This is an unattended scheduled run. …`). - after (this branch build): run `ok`; the bot sent one DM message, exactly `QA-SUBAGENT-DIRECT-FALLBACK-OK` (30 chars). - The recorder needed a `tools` field on its `cron` action to pass `--tools`; that harness tweak was local and is not part of this PR. - Live model, Telegram Test Server: same recorder, one isolated announce cron job to the DM, a live OpenAI model behind the provider slot (`tools.toolSearch: false`). The live parent chose `sessions_spawn` itself and the child answered live. Only the parent's turn after the accepted spawn was steered to end empty, because that is the spawn-only shape under test (a parent that writes text or `NO_REPLY` never reaches this read). - before (origin/main `e44e2640877` build): run `ok`; the child answered `Titan.` live, but the bot sent one DM message of 957 chars: the cron prompt (`LIVE-SPAWN-ONLY check: call sessions_spawn exactly once …`) plus the scheduler preamble. - after (this head `eda6043d497` build): run `ok`; the child answered live and the bot sent one DM message, exactly the child's answer: `Titan is the largest moon of Saturn.` LOC vs origin/main: production +4/−1, tests +22/−7, QA scenario +4. Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #150432
What Problem This Solves
Automation prompts can look like human input, while forwarded automation results expose a run identifier instead of the automation name.
User Impact
Chat identifies automation input and results by the current automation name with an inline clock. Renamed jobs show their current name; deleted jobs use “Automation.” The attribution link opens the source run.
Why This Change Was Made
The cron producer records structured provenance without changing the prompt or stored transcript text. Gateway history owns display projection and current-name lookup, including cached history. The transcript keeps automation attribution outside the assistant execution frame.
Automation headers use the linear presentation from @vyctorbrzezowski’s #150440: clock and name without a pill, with a middle dot when an agent prefix is present. That PR’s collapse and avatar changes remain separately scoped.
Evidence
6a7b1e41d2812f18e4b130efa5efc1c0f1663244, preserving subagent provenance, cron admission, and retained history-reader ownership.ENOTEMPTY). The fixture, assertions, and thresholds are unchanged.Risk and coverage
The shared history consumers checked are the cron transcript recorder, RPC history pages, HTTP snapshots, message normalization, grouping, transcript item reuse, and forwarded-source rendering. The rebase preserves subagent coordination visibility and the current cron admission owner. Ordinary session forwarding, unmarked historical text, heartbeat events, retries without the generated prefix, and source-link hydration have regression coverage.
This adds optional provenance fields without a database migration or configuration change. Historical unmarked cron-looking text is deliberately preserved. Screenshots use synthetic data; no live automation or external provider was run for this landing validation. No startup budget was increased. Collapse, neighboring message geometry, and the separately requested avatar work are outside this change.
Additional local session-reclamation stress checks were inconclusive: the PR run observed an unexpected FTS count, while the baseline exceeded the existing heartbeat threshold (910 ms / 500 ms). The fixture and reclamation/indexing writers are unchanged by this PR; the complete hosted shard is covered by final-revision CI. These local attempts are not counted as passing proof.