Repository navigation
fix(cron): include untruncated agent output in webhook delivery - #186366
wangmiao0668000666 wants to merge 1 commit into
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: blocked before merge. What this changesAdds complete final agent text as outputText in primary webhooks for isolated and current-session automation runs. Example: An isolated automation produces a 3,938-character final report.
Review scores
ProductKind: Feature · Worth it: Needs a maintainer decision · Fix scope: Partial Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: the focused implementation has credible runtime proof and no identified correctness defects, but the additive webhook contract still needs an owner decision. Priority: P2 Decision needed
Before merge
FindingsNone. Agent review detailsHow this fits togetherThe cron runner receives agent results, delivers primary webhooks through the Gateway transport, and separately projects bounded results into history and client events. flowchart TD
A[Scheduled agent turn] --> B[Isolated runner]
B --> C[Cron execution result]
C --> D[Primary webhook event]
D --> E[Gateway HTTP transport]
C --> F[History and client projection]
Technical reviewBest possible solution: Preserve bounded summaries and existing delivery ownership while exposing approved full output through the smallest webhook projection. Do we have a high-confidence way to reproduce the issue? Current-main source drops the existing detached outputText before webhook construction, consistent with the contributor's supplied red CLI/Gateway trace; no target code was executed during this review. Is this the best way to solve the issue? Forwarding the existing full-text value through the existing webhook owner is the smallest implementation for the declared scope, and the three added tests protect distinct transport-visible boundaries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 445e5666f59f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +22, Tests +82, Docs +13. Total +117 across 7 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed October 30, 2026, 12:53 AM ET / 04:53 UTC (Revision 3). |
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Closing this as a stop-loss, not a rejection of the fix. Status at close
What the blocker actually is This PR is an additive extension of a public webhook payload contract — a new Tracking The bug stays tracked in #185873, which remains open. Anyone picking it up should start from the recommendation there:
This branch's diff (detached/isolated half only; the named-session half was disclosed as out of scope under Fix scope) is a usable reference for that work if the owner wants Happy to reopen or re-submit if a cron owner wants this field. Thanks to ClawSweeper for the review. |
Related: #185873
What Problem This Solves
Cron webhook deliveries truncate long agent output: the finished-event payload only
carries the bounded
summary(2,000 characters +…), so a webhook receiver silentlyloses the rest of an otherwise successful report. Issue #185873 reproduces this on a
2,718-character reply; this change adds an additive, webhook-only
outputTextfieldthat carries the run's full final agent text for isolated and current-session
agent-turn jobs, with the bounded
summaryleft byte-for-byte unchanged.ClawSweeper's recommendation on the issue:
This PR implements the recommendation's detached/isolated half with the three
required boundaries (long output, silent replies, failed runs). The named-session half
is disclosed below under Fix scope — it cannot be delivered without editing
src/cron/service/state.ts(occupied by #185848) and adding new capture through theauto-reply owner.
Why This Change Was Made
runIsolatedAgentJobreturnsoutputTextas "Last non-empty agent text output (not truncated)"(
src/cron/service/state.ts:245-246), produced bysrc/cron/isolated-agent/run-finalize.ts:390,407. It was simply dropped by theexplicit field enumeration in the detached branch of
src/cron/service/timer-execution.tsbefore the webhook event was assembled insrc/cron/service/timer-job-runner.ts.pickSummaryFromOutput(src/cron/isolated-agent/helpers.ts:67-74) is untouched, andpersisted run history,
openclaw automations runs, and chat announcements keep thebounded
summary. The new field is projected only into the primary webhook payload(
delivery.mode: "webhook"); the persistence codec enumerates fields(
src/cron/run-event-codec.ts,src/cron/store/run-result.ts), so nothing new isstored or fanned out to Gateway clients.
no existing field or cap modified).
User Impact
final report in
outputTextwhenever it is non-empty; thesummarythey alreadyconsume is unchanged.
summary,no diagnostics, and now explicitly no
outputText).option, validator, or persisted state was added.
docs/automation/cron-jobs/payloads.md): main-sessionand named-session (
session:<key>) agent turns do not carryoutputTextyet.Evidence
364c0d4ebcd400ee4285eb989ed60d2a8b000b93(themainthis patch wasproven against on 2026-10-27; every red/green leg below ran there)
ccdf3ec35a9969c4b4bf2b5cb3baa99990312acfa6a54c9b7…— the identical seven-file change rebuilt directly onmain2742aa016…on 2026-10-29 (details under Rebuild). The 2026-10-28mainmerge that3526945…recorded is gone: that merge left GitHub computing thisPR's diff against a stale merge base, which surfaced as 905 changed files,
CONFLICTING, a falsesecurity-sensitive-changed, and an unreadableThis branch has conflictsUI.the same loopback harness (isolated Gateway state under
/tmp, zero-credentialOpenAI-compatible model stub returning a 3,939-character final answer, loopback
webhook receiver recording raw bodies).
Unit red/green (vitest, one file)
node_modules/.bin/vitest run src/cron/service.persists-delivered-status.test.ts --maxWorkers=1sends untruncated outputText while the summary keeps its bounded shapefails:expected undefined to be 'CRON_FULL_OUTPUT_PROOF_…'(webhook body has nooutputTexton base)The two boundary tests (
omits outputText when the run produced no non-empty output text,keeps failed-run webhooks free of both summary and outputText) pass on bothlegs: they lock the additive contract's absent-key behavior.
Shipped-CLI × live Gateway proof (base red / candidate green)
Both legs:
node <dist>/index.js gateway run --port 18999(real Gateway, isolatedOPENCLAW_STATE_DIR),automations add --webhook http://127.0.0.1:18991/hook --session isolated --model stub/stub-long,automations run <job> --wait, thenautomations runs <job> --limit 1 --sort desc --jsonplus the receiver's raw body log.Leg script:
bash /tmp/oc-cron1-proof/run-leg.sh <red|green> <dist>/index.js.OpenClaw 2026.10.7 (364c0d4))bash /tmp/oc-cron1-proof/run-leg.sh red /media/vdc/oc-cron1/dist/index.jsstatus:"ok",deliveryStatus:"delivered"; nooutputTextkey;summarylength 2001, ends with…,summaryEqualsFullText:false(full text 3,939 chars) — issue reproducedcommit: ccdf3ec35…)bash /tmp/oc-cron1-proof/run-leg.sh green2 /media/vdc/oc-cron1/dist/index.js(identical rerun of the first green leg; both exit 0)status:"ok",deliveryStatus:"delivered";outputTextpresent with the complete final text (3,938 chars, equals the stub's full answer trimmed of surrounding whitespace);summarystill 2,001 chars ending…, byte-identical to the red leg (md5match)Green leg output (candidate dist, build-info commit ccdf3ec35)
outputTextEqualsTrimmedFullText: truecompares the delivered field against thestub's complete 3,939-character answer trimmed of surrounding whitespace
(the value is 3,938 characters; the stub text ends in a space from its repeat
unit) — no internal truncation.
Boundary coverage (Recommendation requirement)
outputTextequals the full textwith only surrounding whitespace trimmed (3,938 characters; no internal
truncation),
summaryremains exactly 2,001 characters ending in…(byte-identical between red and green legs:
summary_md5_match: true).outputText: undefinedandwhitespace-only
outputTextboth omit the key from the JSON body; the existingsuccess-with-empty-summary suppression (
deliverySuppressionReason: "empty", noPOST) is unchanged.
status:"error", asummary, and output text delivers the error webhook without
summary,diagnostics, or
outputText;errorandstatuskeep their existing shape.Summary cap untouched (control)
pickSummaryFromOutput(src/cron/isolated-agent/helpers.ts:67-74) and the2,000-character diagnostics cap (
src/cron/run-diagnostics-normalize.ts:12) are notmodified. In the shipped proof the
summarystring is byte-identical on the red andgreen legs (
md5match), andopenclaw automations runs --jsonshows the same2,001-character summary with no
outputTexton both legs — the new field iswebhook-only.
Fix scope (disclosure)
sessionTarget: "isolated"and"current"agent turns(the
runIsolatedAgentJobpath), which own the untruncated text end-to-end.main/session:<key>) agent turns. The full text ofthose turns exists only inside the session-event handoff
(
src/auto-reply/reply/session-event-handoff.ts:438,summary ??= truncateUtf16Safe(payload.text, 2000)); the settled contractSessionEventOutcome(src/auto-reply/reply/session-event-contract.ts:32-52)exposes only the bounded
summary,runCronSessionTurn(
src/cron/session-run.ts:295) forwards only that summary, and the scheduler'srunSessionEventreturn type is declared insrc/cron/service/state.ts:267-271—a file held by open PR feat(cron): configurable default delivery and failure destinations #185848 and excluded from this change. Covering that half
requires a
state.tscontract change plus new capture through the auto-reply owner;it is intentionally left for a follow-up with the cron owner.
Impact surface
src/cron/types.ts:163-168CronEventgains optionaloutputTextwith ownership commentsrc/cron/types.ts:272-273CronJobExecutionResultgains optionaloutputTextsrc/cron/service/timer-execution.ts:437-442, 552-555res.outputText(was dropped by explicit enumeration)src/cron/service/timer-job-runner.ts:170-174outputTextspreadsrc/gateway/server-cron-notifications.ts:222-228outputTextalongside the existing summary/diagnostics stripsrc/cron/service.persists-delivered-status.test.ts:205-285sendGatewayCronWebhook, real HTTP body)docs/automation/cron-jobs/payloads.md:230-241,docs/cli/cron.md:208outputTextand its boundariesIsolation from #185848 (occupies
src/cron/service/state.ts,src/cron/service/ops-stream.ts,failure-alerts.ts,run-recovery.ts,src/cron/delivery-*.ts,src/cron/isolated-agent/run-delivery-trace.ts,src/cron/store/*.ts,src/gateway/server-cron-completion.ts(+test),src/gateway/server-methods/cron-add.ts,cron-input-validation.ts,docs/automation/cron-jobs/delivery.md,src/config/*cron*,src/agents/tools/cron-tool.*): zero files in common.CronServiceDeps.sendCronWebhookandCronEventContextsignatures are unchanged;the whole change routes through
types.tsoptional fields plus the webhook eventliteral in
timer-job-runner.ts. Collision check was run against the current open-PRfile map (
gh pr list --state open --limit 200 --json number,files): none of the seventouched files appear in any open PR.
Test-lines justification
No ceiling bump is needed on the rebuilt head.
mainnow carries measured headroom:config/test-lines-baseline.txtreads a 6,320,000 ceiling documented as"Measured bf6a97a1765 plus pending regression additions: 6,312,681 lines. Keep 7,319
lines of bounded headroom for remaining regression work". This PR's +82 test lines
(three behavioral tests plus the loopback helper that drives the real
sendGatewayCronWebhookpath, nothing deleted) fit that reserved headroom, so thebranch does not touch the baseline file at all. Verified on the rebuilt head:
The earlier 2026-10-27/28 discussion of raising the ceiling to 6,286,508 and then to
6,300,526 belonged to the pre-rebuild head, where
main's measured total sat above itsown ceiling and a bump was the only way through; dropping it removes line churn from
config/test-lines-baseline.txt, which several other open PRs also edit.Rebuild
The 2026-10-28
Merge main into fix/cron-webhook-full-outputcommit (3526945…) leftthe PR in a state no maintainer can merge: GitHub reported 905 changed files and
+23708/−8739for a seven-file fix,
mergeable: CONFLICTING, andsecurity-review-requiredtriggeredby auth/secrets paths that existed only in that phantom diff (
gh pr diffrefused withHTTP 406: the diff exceeded the maximum number of files (300)).The branch was rebuilt as one commit on
main2742aa016…instead of carrying a mergecommit. The result:
3526945…)a6a54c9b7…)mergeableCONFLICTINGMERGEABLEopenclaw/security-sensitive-reviewchannel: *,app: *,extensions: *,size: XL,security-review-requireddocs,gateway,size: S,proof: sufficient,P2,rating: 🦐 gold shrimp,status: ⏳ waiting on maintainerconfig/test-lines-baseline.txtThe rebuild applied the same patch to current
main: all seven hunks applied cleanly(the only conflict was the baseline line, resolved by keeping
main's headroom version)and no source line changed. Local verification on the rebuilt tree:
pnpm test src/cron/service.persists-delivered-status.test.ts --maxWorkers=1→ 16/16 pass(135.7s, Node 24.22.1),
oxfmt --checkandoxlintclean on the seven files,git diff --checkclean, and the five touched-file ratchets plus the test-lines ratchetOK against
origin/main.Gates
pnpm exec oxlint <5 touched src files>node scripts/run-format.mts --check <5 touched src files>node --import ./scripts/tsx.mjs scripts/format-docs.mts --checkgit diff --checknode_modules/.bin/vitest run src/gateway/server-cron-notifications.test.ts src/gateway/server-cron-primary-webhook.test.ts src/gateway/server.cron.test.ts src/cron/service.trigger-eval.test.ts src/cron/service.session-payload.test.ts --maxWorkers=1server.cronfiles pass 65/65; all failures are inserver.cron.test.ts(next row)node_modules/.bin/vitest run src/gateway/server.cron.test.ts --maxWorkers=1check-line-cap-ratchet,check-max-lines-ratchet,check-test-mock-exports,check-assertion-safety,check-test-timeout-race-ratchet(each--base origin/main --no-merge-base, rerun on the rebuilt head)pnpm check:test-lines-ratcheton the rebuilt headTest lines OK: 6312490; ceiling: 6320000; slack: 7510(no baseline change)pnpm exec tsc -p tsconfig.core.json --noEmitsrc/tui/*-test-support.ts,test/helpers/*); none in touched filespnpm exec tsc -p test/tsconfig/tsconfig.core.test.services-cron.json --noEmitpnpm tsgo@tsrs/linux-x64-gnunative binary requires GLIBC ≥ 2.34; host has older glibc (GLIBC_2.34…2.32 not found). Fallback: fulltscruns above + CICleanup
/tmp/oc-cron1-proof/(state-red/,state-green/,JSONL webhook logs); Gateway, model stub, and webhook receiver are terminated by the
leg script's
trap cleanup(explicitkill <pid>, nopkillmatching the agent'sown command line). Loopback ports only (18991/18992/18999).
a loopback OpenAI-compatible server with a synthetic key; the webhook receiver is a
loopback HTTP sink.
Not tested
main/session:<key>) webhook output — intentionally out of scope(see Fix scope); the issue's original repro used
sessionTarget: "session:veille-ia",so that lane's webhook payload remains summary-only until the follow-up lands.
(
pnpm test <file> --maxWorkers=1equivalents above).completionDestination(announce-mode completion webhook) payload is unchanged:its event is built from the persisted run-result projection, which does not carry
outputTextby design.Maintainer edits
pickSummaryFromOutput, diagnostics cap) is untouched.outputText: ""; the boundary tests lock that absent-key behavior.docs/automation/cron-jobs/payloads.md+docs/cli/cron.mdbecausewebhooks.mdis the inbound Gateway-hooks page (declares itself separate from outbound delivery) and the canonical outbounddelivery.mdis occupied by feat(cron): configurable default delivery and failure destinations #185848 — move the doc line there once feat(cron): configurable default delivery and failure destinations #185848 lands if preferred.Maintainer options
state.tscontract change (file occupied by feat(cron): configurable default delivery and failure destinations #185848) plus new capture through the auto-reply owner, which violates the additive/no-new-capture scope this PR is holding to. Recommended instead: land this half, follow up with the cron owner forsession:<key>.summarywith the full text: rejected; the maintainer explicitly preserved the 2,000-character cap, and run history / announcements /automations runsdepend on the bounded shape (proven unchanged).Additional instructions: Keep Allow edits from maintainers enabled
Maintainers may push directly to this branch (Allow edits from maintainers stays
enabled), including scope reductions, follow-up split, or landing as-is.