Repository navigation
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 real behavior proof before merge. What this changesThis PR passes the resolved destination and thread to CLI-backed cron runs and skips channel-plugin resolution for unthreaded targets. Example: An isolated CLI cron targets Telegram chat -1003774691294, topic 47, and starts a background command.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Blocked before merge - 6 items remain Keep this PR open: current main still omits the CLI topic route, and the work has assigned ownership; the patch needs a plugin compatibility repair and a corrected completion regression. Priority: P1 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe cron executor supplies resolved delivery context to agent runners; CLI grants carry it into tools, whose background completions enter session-event execution and outbound delivery. flowchart TD
A[Cron delivery target] --> B[Cron executor]
B --> C[CLI runner]
C --> D[Loopback tool grant]
D --> E[Background exec completion]
E --> F[Session event owner]
F --> G[Channel outbound delivery]
Technical reviewBest possible solution: Preserve channel-owned target normalization and carry the CLI route through the current completion owner with source-authority checks before delivery. Do we have a high-confidence way to reproduce the issue? Current-main source confirms the CLI recipient/thread omission and its downstream exec-notification inputs; the linked report supplies official-release observations, but no current-main runtime reproduction was executed. Is this the best way to solve the issue? Resolving the route once at the cron producer is appropriate, but skipping the public unthreaded resolver changes an unrelated contract and the completion test must follow today's session-event owner. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d54483901779. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: The route repair addresses a reported disclosure, but exact originating-source authority remains unverified at delayed delivery. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +10, Tests +264. Total +274 across 5 files. Added test files: 1. 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. 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 (6 earlier review cycles)
Reviewed October 10, 2026, 4:50 AM ET / 08:50 UTC (Revision 7). |
|
Telegram Test Server proof status and a request for a maintainer. The harness is ready at Request, whichever is easier for the team:
Until then the PR's proof stays boundary-level (executor-to-runner seam plus the traced grant, tool-resolution, and exec-notify chain). |
|
Applied the P2 in |
|
Rebased onto |
abb948e to
0c55908
Compare
|
Maintainer-approved scope for the connected continuation repair: Live native-runtime proof shows that immediate sends and both delayed command replies reach the originating Telegram topic, while both delayed replies also enter main-session history. The CLI handoff change alone cannot remove those history copies. For future isolated cron shell work, the original run will own its delayed replies through final delivery. The repair will extend the existing exact-run continuation owner, retaining its runtime, tool policy, lifecycle revision and cancellation checks until pending shell completions and deliveries settle. Existing history will remain unchanged. No schema-version bump, new store, or unrelated event-producer policy change is approved. Verification must cover native and CLI topic delivery, multiple completions without duplicates, absence from main history and unrelated conversations, cancellation, overlapping runs, restart recovery, and existing delivery overrides. The contributor's route repair and credit will be preserved. This records the accepted design; implementation and verification are still in progress. |
|
@obviyus thanks for recording the design. Who is implementing the continuation-owner extension, and does it land on this PR or on top of it? If you want it here, I can start today. Otherwise I will keep this PR scoped to the CLI route repair and rebase it once you confirm. |
|
I’m implementing the continuation-owner extension on this PR and will preserve your existing commits and credit. The native topic flow is verified; the CLI and lifecycle checks are in progress. Please leave the branch as it is while I finish the repair and verification. Thanks @ylcn91. |
|
I reproduced a higher-impact variant of this bug: a delayed CLI-backed exec completion lost its Telegram route, entered the agent main session, and was actually sent to an unrelated Telegram group. I documented the sanitized incident in #138316. I opened #147283, preserving all three commits and original authorship from this PR, and added a defense-in-depth fail-closed boundary: route-less or conflicting exec completion batches are consumed before model dispatch, so no model/session fallback can guess a recipient. If maintainers prefer to keep this PR, the standalone hardening commit is KirDE/openclaw@36a19bce40. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
The isolated cron executor resolved the channel-native current-channel id only inside its embedded branch, so a CLI-backed run (Codex app-server and every other CLI provider) reached `runCliAgent` with `messageChannel` and `agentAccountId` but no recipient/thread. `buildCliMcpGrantContext` then minted a loopback grant without `currentChannelId`/`currentThreadTs`, and `createExecTool` built `notifyDeliveryContext` with an empty target — so a background exec completion carried no route and the later heartbeat relay fell back to the owner DM. Resolve the route once above the runtime branch and hand it to both runners; the CLI runner takes it as `currentChannelId` plus `currentThreadTs`, its vocabulary for the embedded `messageTo`/ `messageThreadId` pair. User impact: Telegram forum-topic (and any threaded-channel) automations on a CLI runtime keep background exec completions and message-tool sends in their originating topic instead of leaking topic-local operational output into the owner's DM. Fixes openclaw#138316
…gets `resolveCurrentChannelTarget` loaded the channel-plugin runtime for every targeted cron run, but only a thread needs channel-specific conversion (the one implementer returns the target unchanged without one). An unthreaded route now returns its target directly, so CLI-backed runs regain the direct path they had before the route was resolved above the runtime split.
The existing regression test stops at the executor-to-CLI parameters, so no proof covered the four production owners the route crosses afterwards. This drives the real loopback grant, gateway tool resolution, exec notify queue, and heartbeat delivery with a real background process and asserts the delayed completion is delivered to the originating forum topic. On the merge-base the same test fails at the delivery boundary: `expected '<owner-dm>' to be '<chat>:topic:47'`.
0c55908 to
965eae9
Compare
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
What Problem This Solves
A Telegram forum-topic cron whose run selects a CLI runtime (Codex app-server,
openai/gpt-5.6-sol) loses its topic route. Backgroundexeccompletions fromthat run are relayed later by the heartbeat turn into the owner's DM instead of
the originating topic, leaking topic-local operational output into an unrelated
conversation and contaminating
agent:main:main.src/cron/isolated-agent/run-executor.tsresolved the channel-nativecurrent-channel id only inside its embedded branch. The CLI branch called
runCliAgentwithmessageChannelandagentAccountIdbut norecipient/thread, so
src/agents/cli-runner/mcp-grant-context.ts:140,181minted a loopback grant with no
currentChannelId/currentThreadTs,src/gateway/tool-resolution.ts:500-501forwarded the gap into the execdefaults, and
src/agents/bash-tools.exec-run.ts:161-166builtnotifyDeliveryContextwith an empty target. The downstream heartbeat can onlyprefer a route the queued event already carries; it cannot restore fields that
were absent before the completion was queued.
Fixes #138316. Follow-up to #138269, which was closed after reviewing the
embedded path only.
Why This Change Was Made
The violated invariant is that both runtime branches of the cron executor hand
the runner the same resolved delivery route. Rather than duplicating the
resolution,
resolveCurrentChannelTargetnow runs once above theif (cliExecution)branch and both runners consume it. The CLI runner takes itas
currentChannelIdpluscurrentThreadTs;RunCliAgentParams(
src/agents/cli-runner/types.ts:237,240) has nomessageTo/messageThreadId,so those are its vocabulary for the same fact. This matches the sibling CLI
caller
src/auto-reply/reply/agent-runner-cli-candidate.ts:404,416, whichalready passes both.
All six
runCliAgentcall sites were checked.src/agents/embedded-agent-runner/cli-backend-dispatch.tsdeliberately dropsdelivery context for its one-shot bridge (documented in place) and is
unreachable from cron, which never sets
cliBackendDispatch.Codex gate: this change is OpenClaw-side plumbing only. Nothing under
extensions/codex/or the Codex harness contract is touched; the Codexapp-server is one of the CLI providers routed through
isCliProvider, and therepair is provider-generic.
Production delta +16/-6, of which 6 lines are comments: net +4 code lines. No
new config, no schema change, no fallback path.
User Impact
Telegram forum-topic, and any threaded-channel, automations running on a CLI
runtime keep their background exec completions and message-tool sends in the
originating topic. Embedded-runtime behavior is unchanged; the resolution simply
moved above the branch.
Evidence
src/cron/isolated-agent/run.message-tool-policy.test.ts("forwards the resolved topic route into the CLI run") is the CLI twin of the
existing embedded cases. Pre-fix, with production reverted:
CLI run params.currentChannelId: expected undefined to deeply equal 'room#42'(1 failed | 59 skipped). Post-fix: 60/60 pass.
node scripts/run-vitest.mjs src/cron/isolated-agent: 55 files, 849/849 pass.node scripts/run-vitest.mjs src/agents/cli-runner/mcp-grant-context.test.ts src/agents/cli-runner/prepare.test.ts: 153/153 pass.node scripts/check-changed.mjs -- src/cron/isolated-agent/run-executor.ts src/cron/isolated-agent/run.message-tool-policy.test.ts: exit 0 (format, core + core-test typecheck, lint, dead-export scan, import cycles, plugin boundaries, all guards).origin/main):patch is correct, no findings.qa/convex-credential-broker), and this checkout's authenticated Convex account is not a member of that project (convex env ... getanswersYou don't have access to the selected project); noOPENCLAW_QA_CONVEX_SITE_URL/OPENCLAW_QA_CONVEX_SECRET_CIpair is available either, sotelegram-test-doctor.mjscannot lease. Everything else is ready atffc2ed1(pnpm buildexit 0,dist/entry.js, harness prerequisites) and the scenario needs no harness edits:--backend claude-cliselects the CLI runtime this PR changes (resolveCliRuntimeExecutionProvider,extensions/anthropic/openclaw.plugin.jsoncliBackend), acommandaction creates a forum topic and an isolated announce cron withopenclaw cron add --thread-id <topic>, runs it with--wait, and a120 stail withtools.exec.notifyOnExit: trueplus a 1-minute heartbeat catches the delayed exec completion; the recorder already reportstopicIdper row, so the decisive fact is a SUT message containing the marker whosetopicIdequals the created topic (pre-fix it lands without one). A maintainer with broker access can run it as is; I will attach the timeline as soon as the lease is possible.cli-backend-dispatch.tsdrops the samecontext by design for opt-in
cliBackendDispatch: "subscription-auth"runs.ClawSweeper review of
ffc2ed1, item by item:0e6c68f, at the owner rather than the call site.resolveCurrentChannelTarget(src/cron/isolated-agent/channel-output-policy.ts) loaded the channel-plugin runtime for every targeted run, but only a thread needs channel-specific conversion: the single implementer ofthreading.resolveCurrentChannelId(Telegram,extensions/telegram/src/channel.ts:1188) returnstounchanged whenthreadId == null. An unthreaded route now returns its target before the runtime loader runs, so a CLI-backed run with no thread has the direct path it had before the route was resolved above the runtime split, and embedded runs lose a no-op plugin load; threaded routes still resolve through the plugin. Regressionkeeps an unthreaded target without consulting the channel plugin(owner test) assertsgetChannelPluginis never called forthreadId: nullor omitted; onffc2ed1it fails withexpected "vi.fn()" to not be called at all, but actually been called 2 times.0e6c68fis +3/-1 production (one condition plus its comment) and +11 test lines.0e6c68f(Node 24.18.0, Linux):pnpm test src/cron/isolated-agent/channel-output-policy.test.ts src/cron/isolated-agent/run.message-tool-policy.test.ts(64 tests);node scripts/check-changed.mjs -- src/cron/isolated-agent/channel-output-policy.ts src/cron/isolated-agent/channel-output-policy.test.ts(clean); autoreview (Claude engine, P1 threshold,--mode commit):patch is correct (0.75), no findings.Boundary proof through the real delayed-completion path (
abb948e)The earlier proof stopped at the executor-to-CLI parameters.
abb948eaddssrc/cron/isolated-agent/run.cli-topic-delivery.e2e.test.ts(standalone e2elane,
test/vitest/vitest.e2e.config.ts), which drives the route the reviewasked for with production code end to end: the isolated cron executor
(
executeCronRun, the changed owner), the real loopback grant(
buildCliMcpGrantContext), real gateway tool resolution(
resolveGatewayScopedTools,surface: "loopback", mediatedexec), a realbackground
execchild process withnotifyOnExit, the real system-eventqueue, and a real heartbeat turn (
runHeartbeatOnce) that selects the routeand delivers through the channel outbound adapter. Only two edges are
replaced: the CLI subprocess (
runCliAgent, its received parameters are thefact under test) and the Telegram network send (
deps.telegram, a recordingspy at the mock-Gateway boundary). The sandbox is the existing
withTempTelegramHeartbeatSandboxfixture (isolatedOPENCLAW_STATE_DIR,temp SQLite session store, no port bound, no Gateway touched). Telegram's
resolveCurrentChannelIdtarget grammar (<chat>:topic:<id>,extensions/telegram/src/channel.ts:1188) is supplied on the plugin facade;Telegram is the only implementer of that hook in the repo.
Pre-fix (production
run-executor.tsandchannel-output-policy.tsreverted tothe merge base
a049778, everything else atabb948e), exit 1:The heartbeat really ran and really delivered the delayed exec completion, to
the session's last target (the owner DM) instead of the forum topic. The queued
system event carried
to: undefinedin that run, which is the #138316mechanism.
Post-fix (
abb948eas is), exit 0:The queued completion carries
deliveryContext { channel: "telegram", to: "-1003774691294:topic:47", accountId: "ops", threadId: "47" }and theoutbound send is called once with
"-1003774691294:topic:47".Also on
abb948e:node scripts/run-vitest.mjsoverrun.message-tool-policy.test.ts,channel-output-policy.test.tsand the newfile, 65/65 pass; the new file co-resident with the other three
src/cron/isolated-agent/*.e2e.test.tsfiles in theisolate: falsee2e lane,4 files / 18 tests pass;
oxfmt --checkandoxlintclean;scripts/run-tsgo-core-test-shards.mjsexit 0.What this still does not observe: a message in a real Telegram forum topic. The
Test Server lease is still blocked on broker access as described above, so the
unobserved segment is now the adapter-to-Telegram network hop only. The
prepared live scenario is unchanged and a maintainer with broker access can run
it as is.
Rebase onto
main(e8684576989)Main still omits the topic route on the CLI branch:
resolveCurrentChannelTargetruns only for the embedded runner andrunCliAgentreceives nocurrentChannelId/currentThreadTs. Conflicts were re-expressed on main's current code:run-executor.ts: main introducedbuildCommonRunParams()and moved the CLI call insidewithLocalSessionPlacementTurnSettlement/deferredLifecycle.resolveCurrentChannelTargetnow runs once beforeif (cliExecution); the CLI call addscurrentChannelIdandcurrentThreadTs: normalizeOptionalStringifiedId(threadId); the embedded call keeps the same value.currentThreadTsis not put in the common params, so embedded behavior is unchanged.run.message-tool-policy.test.ts: main rewrote this file and removedcreateMessageToolExecutor/expectRecordFields. "forwards the resolved topic route into the CLI run" is rewritten in the file's current idiom (mockCliAnnounce,runCronIsolatedAgentTurn,expectFields(mockCall(runCliAgentMock)[0], …)) on the existingtopicchat(room#42) fixture.channel-output-policy.tscommit replayed cleanly; Telegram is still the onlythreading.resolveCurrentChannelIdimplementer (extensions/telegram/src/channel.ts:1020).run.cli-topic-delivery.e2e.test.tsadapted to moved APIs:createSourceDeliveryPlan→resolveCronSourceDeliveryPlan(./source-delivery-plan.js);executeCronRunnow requiresrunId,deliveryAttemptFence, andonPromptAdmission;resolveGatewayScopedToolsis awaited.The test numbers above are from the previous base; CI on this head is the gate for the re-run. The ClawSweeper medium item (delayed delivery retaining stale route authority after reset/reassignment) and the Telegram Test Server proof remain open as described above.