openclaw - 💡(How to fix) Fix [Bug]: async exec completion relay asks user for missing logs after No session found [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#74595Fetched 2026-04-30 06:22:28
View on GitHub
Comments
2
Participants
3
Timeline
9
Reactions
2
Author
Timeline (top)
mentioned ×3subscribed ×3commented ×2closed ×1

Async/background exec completion events can produce user-visible assistant messages that say the runtime cannot retrieve the completed command output because the referenced exec/session id no longer exists (No session found).

This is worse than a missing completion notice: the model asks the user to paste command output or explain what the command was, even though the command was launched by OpenClaw and should either have its result attached to the completion event or be consumed silently.

Error Message

  1. If output is missing for a failure, send a concise runtime error that includes enough stable metadata for debugging. [agent/embedded] [context-overflow-diag] sessionKey=<redacted-telegram-direct-session> provider=openai-codex/gpt-5.5 source=assistantError messages=199 ... error=Context overflow: estimated context size exceeds safe threshold during tool loop. That !hasExecCompletion exception appears to make exec-event turns more likely to leak user-visible fallback text even when there is no useful payload to relay.
  • Only deliver user-visible async completion text when there is meaningful output, an error, or an explicit user-facing completion request.
  • Remove the hasExecCompletion exception from heartbeat skip handling unless the event has a non-empty, relayable payload.

Root Cause

Async/background exec completion events can produce user-visible assistant messages that say the runtime cannot retrieve the completed command output because the referenced exec/session id no longer exists (No session found).

Code Example

I got a completion notice for an earlier async command (<short exec id>, exit code 0), but the runtime didn’t include the command’s stdout/stderr, and I can’t retrieve logs for it (no matching session found).

If you tell me what that command was supposed to do (or paste its output if you have it), I’ll summarize the result and confirm everything looks right.

---

I can’t retrieve the output for that completed command right now: the exec session id you provided (<opaque-event-id>) isn’t available (“No session found”), so there are no logs for me to relay.

If you paste the command output here (or tell me what command it was), I’ll summarize it cleanly and call out anything important.

---

[heartbeat] using explicit accountId
[agent/embedded] [context-overflow-diag] sessionKey=<redacted-telegram-direct-session> provider=openai-codex/gpt-5.5 source=assistantError messages=199 ... error=Context overflow: estimated context size exceeds safe threshold during tool loop.
...
[gateway] ready
[heartbeat] started
[heartbeat] using explicit accountId

---

function buildExecEventPrompt(pendingEvents, opts) {
  ...
  if (!eventText) return "An async command completion event was triggered, but no command output was found. Reply HEARTBEAT_OK only...";
  ...
  return "An async command you ran earlier has completed. The command completion details are:\n\n" + eventText + "\n\nPlease relay the command output to the user...";
}

---

const execFallbackText = hasExecCompletion && !normalized.text.trim() && replyPayload.text?.trim() ? replyPayload.text.trim() : null;
...
const shouldSkipMain = normalized.shouldSkip && !normalized.hasMedia && !hasExecCompletion;
RAW_BUFFERClick to expand / collapse

Bug type

Bug / async exec completion relay / user-visible internal followup

Summary

Async/background exec completion events can produce user-visible assistant messages that say the runtime cannot retrieve the completed command output because the referenced exec/session id no longer exists (No session found).

This is worse than a missing completion notice: the model asks the user to paste command output or explain what the command was, even though the command was launched by OpenClaw and should either have its result attached to the completion event or be consumed silently.

Environment

  • OpenClaw: 2026.4.26 (be8c246)
  • OS: Ubuntu / Linux 6.17.0-22-generic x64
  • Install method: npm/global under linuxbrew
  • Gateway: local systemd user service, loopback 127.0.0.1:18789
  • Surface: Telegram direct chat
  • Model: openai-codex/gpt-5.5 / default openai-codex/gpt-5.2
  • Affected runner path: background exec completions and cron/heartbeat exec-event relay

Expected behavior

When a background exec completes, OpenClaw should do one of these:

  1. Relay a completion summary with the command output/result attached, or
  2. If output is missing/unavailable and exit code is success, consume the event silently / emit HEARTBEAT_OK internally, or
  3. If output is missing for a failure, send a concise runtime error that includes enough stable metadata for debugging.

It should not ask the end user to provide command output that OpenClaw itself lost.

Actual behavior

The Telegram user receives messages like:

I got a completion notice for an earlier async command (“<short exec id>”, exit code 0), but the runtime didn’t include the command’s stdout/stderr, and I can’t retrieve logs for it (no matching session found).

If you tell me what that command was supposed to do (or paste its output if you have it), I’ll summarize the result and confirm everything looks right.

And:

I can’t retrieve the output for that completed command right now: the exec session id you provided (<opaque-event-id>) isn’t available (“No session found”), so there are no logs for me to relay.

If you paste the command output here (or tell me what command it was), I’ll summarize it cleanly and call out anything important.

This has happened repeatedly after successful background/cron-ish commands. The referenced ids are not available through the process/session tools by the time the relay model tries to inspect them.

Evidence / relevant local observations

Recent gateway logs around one incident show the async relay wake and the gateway operating normally, but no retrievable exec output is delivered to the model:

[heartbeat] using explicit accountId
[agent/embedded] [context-overflow-diag] sessionKey=<redacted-telegram-direct-session> provider=openai-codex/gpt-5.5 source=assistantError messages=199 ... error=Context overflow: estimated context size exceeds safe threshold during tool loop.
...
[gateway] ready
[heartbeat] started
[heartbeat] using explicit accountId

Earlier diagnostics show the same class of issue with orphan completion prompts. The relay prompt instructs the model to relay output, but the output/session is absent, causing the model to produce a helpdesk-style message to the user.

Relevant built artifact behavior in dist/heartbeat-events-filter-*.js:

function buildExecEventPrompt(pendingEvents, opts) {
  ...
  if (!eventText) return "An async command completion event was triggered, but no command output was found. Reply HEARTBEAT_OK only...";
  ...
  return "An async command you ran earlier has completed. The command completion details are:\n\n" + eventText + "\n\nPlease relay the command output to the user...";
}

And in dist/heartbeat-runner-*.js, exec completions are treated specially so skip handling is not applied the same way as normal heartbeat HEARTBEAT_OK replies:

const execFallbackText = hasExecCompletion && !normalized.text.trim() && replyPayload.text?.trim() ? replyPayload.text.trim() : null;
...
const shouldSkipMain = normalized.shouldSkip && !normalized.hasMedia && !hasExecCompletion;

That !hasExecCompletion exception appears to make exec-event turns more likely to leak user-visible fallback text even when there is no useful payload to relay.

Suspected root cause

Two separate problems seem to combine:

  1. The exec completion system event contains only partial completion metadata, or references an exec/session id whose logs have already been cleaned up / are not visible to the relay session.
  2. The heartbeat exec-event relay prompt asks the model to produce a user-facing summary even when the only available information is an id + exit code, so the model tries to retrieve logs and then sends the resulting No session found failure to the user.

This is related to async completion routing/session-targeting issues, but this specific failure mode is about missing completion payload + model-mediated relay leaking the absence of runtime context to the user.

Impact

  • Confusing and unactionable Telegram noise after successful automations/background tasks.
  • User is asked to paste output that OpenClaw should already have.
  • Makes successful cron/background jobs look broken.
  • Can repeat frequently when multiple automations/background execs are active.

Suggested fix direction

  • Include durable stdout/stderr/result summary in the exec completion event before process/session cleanup, or persist a log reference that remains available to the relay.
  • If an exec completion has exit code 0 and no output, treat it as silently successful by default.
  • Only deliver user-visible async completion text when there is meaningful output, an error, or an explicit user-facing completion request.
  • Remove the hasExecCompletion exception from heartbeat skip handling unless the event has a non-empty, relayable payload.
  • Add regression coverage for: background exec exits 0 after process session cleanup; heartbeat/exec-event relay should not ask the user for missing logs.

Privacy note

Chat ids, session ids, hostnames, and opaque event ids are intentionally redacted here, but can be provided privately if maintainers need exact local logs.

extent analysis

TL;DR

The most likely fix involves modifying the exec completion event to include a durable stdout/stderr/result summary or persisting a log reference, and adjusting the heartbeat exec-event relay to only deliver user-visible text when there is meaningful output or an error.

Guidance

  • Review the buildExecEventPrompt function in dist/heartbeat-events-filter-*.js to ensure it handles cases where eventText is empty or null, and consider adding a check for the existence of command output before instructing the model to relay it.
  • Modify the shouldSkipMain logic in dist/heartbeat-runner-*.js to remove the !hasExecCompletion exception unless the event has a non-empty, relayable payload, to prevent leaking user-visible fallback text.
  • Consider adding a default behavior for exec completions with exit code 0 and no output, such as treating them as silently successful.
  • Evaluate the feasibility of persisting a log reference that remains available to the relay, to address the issue of missing completion payload.

Example

function buildExecEventPrompt(pendingEvents, opts) {
  ...
  if (!eventText && !pendingEvents.hasOutput) {
    return "An async command completion event was triggered, but no command output was found. Reply HEARTBEAT_OK only...";
  }
  ...
}

Notes

The suggested fix direction involves modifying the exec completion event and the heartbeat exec-event relay. However, the exact implementation details may vary depending on the specific requirements and constraints of the OpenClaw system.

Recommendation

Apply the suggested fixes to modify the exec completion event and the heartbeat exec-event relay, to prevent user-visible async completion text from being delivered when there is no meaningful output or error. This should help to reduce confusing and unactionable Telegram noise after successful automations/background tasks.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When a background exec completes, OpenClaw should do one of these:

  1. Relay a completion summary with the command output/result attached, or
  2. If output is missing/unavailable and exit code is success, consume the event silently / emit HEARTBEAT_OK internally, or
  3. If output is missing for a failure, send a concise runtime error that includes enough stable metadata for debugging.

It should not ask the end user to provide command output that OpenClaw itself lost.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: async exec completion relay asks user for missing logs after No session found [2 comments, 3 participants]