openclaw - ✅(Solved) Fix Isolated session outputs forwarded without main agent awareness [1 pull requests, 8 comments, 4 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#52136Fetched 2026-04-08 01:15:12
View on GitHub
Comments
8
Participants
4
Timeline
26
Reactions
0
Author
Timeline (top)
commented ×8mentioned ×5subscribed ×5cross-referenced ×3

Error Message

  • Agent acts as a pipe: receives → forwards → forgets
  • No internalization of content it delivers
  • Agent cannot answer questions about information it just sent
  • User has to point agent to its own output

Fix Action

Fixed

PR fix notes

PR #52170: fix(cron): write delivered cron output back into main session transcript

Description (problem / solution / changelog)

Summary

tldr: - Cron job outputs delivered to channels were never saved in the agent's session history, so the agent couldn't recall what it sent. This fix writes delivered cron output back into the correct transcript with proper routing and deduplication.

  • Problem: When an isolated cron job delivers a message to a channel (e.g. Telegram/Discord), the main agent has no record of it. Users can ask:

    • "what did you send this morning?" and the agent has no idea — it forwarded the content but never wrote it to its own transcript.
  • Why it matters: The agent acts as a blind pipe — receive, forward, forget. Users expect the agent to recall its own deliveries, especially when asking follow-up questions about content it just sent.

  • What changed:

    • Bug fix: After a successful direct isolated cron announce delivery, OpenClaw now makes a best-effort chat.inject write into the routed main or thread transcript using a stable idempotency key, so the agent can recall what it already sent. New session entries are seeded with delivery context from the main session to avoid creating routing-empty store entries. The chat.inject handler now returns success for idempotent dedup replays instead of a spurious error.

    • Refactor: Session key routing was unified so awareness injection, delivery target resolution, and store writes all use the runtime session key consistently instead of pulling from different sources (job.sessionKey vs the runtime param):

      • resolveCronDeliveryContext (run.ts) — changed from params.job.sessionKey to params.sessionKey so delivery target resolution uses the correct session context for hook dispatches and shared-contract runs.
      • dispatchCronDelivery params (delivery-dispatch.ts) — added a required sessionKey field to DispatchCronDeliveryParams so the runtime session key flows through the delivery dispatch path.
      • resolveDeliveryTarget (delivery-target.ts) — changed to resolve the session store from the session key's agent ID instead of always using the runner's agentId, and added canonicalizeMainSessionAlias so thread/routed keys are properly canonicalized before store lookup.
    • Scope boundary: This does not resend cron output to users, does not switch cron over to the subagent announce flow, and does not change the existing no-fallback-main-summary behavior.

    Change Type (select all)

    • Bug fix
    • Feature
    • Refactor required for the fix
    • Docs
    • Security hardening
    • Chore/infra

    Scope (select all touched areas)

    • Gateway / orchestration
    • Skills / tool execution
    • Auth / tokens
    • Memory / storage
    • Integrations
    • API / contracts
    • UI / DX
    • CI/CD / infra

    Linked Issue/PR

    • Fixes #52136

    User-visible / Behavior Changes

    Successful direct isolated cron announce deliveries now attempt to append a labeled Cron delivery assistant entry into the routed main or thread transcript so later follow-up turns can recall what cron already sent externally.

    Security Impact (required)

    • New permissions/capabilities? No
    • Secrets/tokens handling changed? No
    • New/changed network calls? No
    • Command/tool execution surface changed? No
    • Data access scope changed? No

    Repro + Verification

    Environment

    • OS: macOS
    • Runtime/container: local repo checkout on main plus the fix branch
    • Model/provider: N/A
    • Integration/channel: isolated cron direct announce delivery with routed main or thread transcript awareness
    • Relevant config: test harness session store with agent:main:main and optional thread session entries

    Steps

    1. Configure an isolated cron agentTurn job with delivery.mode="announce".
    2. Let the isolated run produce a normal text response and deliver it through the direct outbound path.
    3. Inspect the routed main or thread transcript after delivery.

    Expected

    • After a successful direct delivery, OpenClaw writes a Cron delivery transcript entry into the routed session.
    • Replayed chat.inject writes for the same run/session combination are deduped by idempotency key.

    Actual Before This Change

    • Direct delivery completed, but the routed transcript did not receive the delivered content.

    Evidence

    • Failing test/log before plus passing after
    • Trace/log snippets
    • Screenshot/recording
    • Perf numbers

    Regression coverage added for:

    • main-session awareness injection
    • thread-session awareness injection
    • idempotent transcript injection behavior through chat.inject
    • runtime session key routing for hook dispatch / shared-contract runs
    • cross-agent awareness store resolution
    • delivery context seeding on new awareness session entries

    Human Verification (required)

    • Verified scenarios:
      • direct isolated cron announce delivery appends a Cron delivery transcript entry to agent:main:main
      • thread-bound cron delivery appends to the routed thread session instead of the generic main session
      • runtime session key is used for awareness when job.sessionKey is absent (hook dispatch path)
      • cross-agent awareness entries are written to the correct agent store
      • new awareness session entries are seeded with delivery metadata so resolveDeliveryTarget doesn't lose lastChannel/lastTo
      • chat.inject dedup replays return { deduplicated: true } instead of an error
      • existing outbound direct delivery still works
      • existing no-fallback-main-summary behavior still holds
    • Edge cases checked:
      • transcript injection uses a stable idempotency key per run/session
      • missing routed session safely skips awareness injection instead of failing the delivery
      • cross-agent sessionTarget resolves store path from the awareness session key's agent, not the runner's agent
      • awareness entries created for keys without prior store entries carry seeded delivery context
    • pnpm test passed
    • Not verified:

    Review Conversations

    • I replied to or resolved every bot review conversation I addressed in this PR.
    • I left unresolved only the conversations that still need reviewer or maintainer judgment.

    Compatibility / Migration

    • Backward compatible? Yes
    • Config/env changes? No
    • Migration needed? No

    Failure Recovery (if this breaks)

    • Revert the transcript-awareness injection in src/cron/isolated-agent/delivery-dispatch.ts
    • Revert the optional idempotencyKey support added to chat.inject
    • Revert the delivery-target routing changes in src/cron/isolated-agent/delivery-target.ts

    Risks and Mitigations

    • Risk: duplicate transcript awareness entries on retries or replays

      • Mitigation: chat.inject now accepts an optional idempotency key and cron uses a stable per-run/session key
    • Risk: routed thread awareness could land on the wrong session

      • Mitigation: the awareness target prefers the explicit runtime session key and falls back to the agent main session only when that routed entry is absent
    • Risk: awareness creates a new store entry for a session key that didn't previously exist, which could affect resolveDeliveryTarget on future runs

      • Mitigation: new entries are seeded with lastChannel/lastTo/lastAccountId/lastThreadId from the main session's delivery context so target resolution behaves the same as the main-session fallback

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • apps/macos/Sources/OpenClawProtocol/GatewayModels.swift (modified, +5/-1)
  • apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift (modified, +5/-1)
  • src/cron/isolated-agent.delivers-response-has-heartbeat-ok-but-includes.test.ts (modified, +11/-1)
  • src/cron/isolated-agent.delivery-awareness.test.ts (added, +568/-0)
  • src/cron/isolated-agent.delivery-target-thread-session.test.ts (modified, +143/-7)
  • src/cron/isolated-agent/delivery-dispatch.double-announce.test.ts (modified, +6/-0)
  • src/cron/isolated-agent/delivery-dispatch.ts (modified, +185/-0)
  • src/cron/isolated-agent/delivery-target.test.ts (modified, +10/-0)
  • src/cron/isolated-agent/delivery-target.ts (modified, +41/-6)
  • src/cron/isolated-agent/run.ts (modified, +60/-2)
  • src/gateway/protocol/schema/logs-chat.ts (modified, +1/-0)
  • src/gateway/server-methods/chat.ts (modified, +7/-0)
RAW_BUFFERClick to expand / collapse

Problem

When an isolated cron job (e.g. bmad-daily) generates output that gets delivered to a channel (Telegram/Discord), the main agent forwards it without ever reading or internalizing the content.

Example

  1. bmad-daily cron runs at 08:00, scrapes BMad changelog, writes to knowledge/bmad/README.md
  2. Output is delivered to Telegram as announcement
  3. User asks main agent: "What's new in BMad v4.30.1?"
  4. Main agent has no idea — it forwarded that exact info hours ago but never read it

Observed behavior

  • Agent acts as a pipe: receives → forwards → forgets
  • No internalization of content it delivers
  • Agent cannot answer questions about information it just sent
  • User has to point agent to its own output

Expected behavior

Some awareness of content passing through — at minimum, main session should be able to recall "I sent something about BMad v4.30.1 this morning" even if it doesn't have full context.

Possible causes (speculation)

  • Isolated sessions have no memory bridge to main session
  • Delivery happens at transport layer, bypasses agent cognition
  • Main agent context doesn't include recent deliveries from its cron jobs

Environment

  • OpenClaw 2026.3.13
  • Cron with sessionTarget: isolated + delivery.mode: announce

extent analysis

Fix Plan

To address the issue, we need to implement a mechanism for the main agent to internalize the content it delivers. Here are the steps:

  • Modify the cron job to store the output in a shared knowledge base or database.
  • Update the main agent to periodically scan the knowledge base for new information.
  • Implement a caching mechanism to store recently delivered content.

Example Code

# cron job (bmad-daily) writes to knowledge base
import json

def scrape_bmad_changelog():
    # scrape BMad changelog
    data = {'version': '4.30.1', 'changes': ['change1', 'change2']}
    with open('knowledge/bmad/README.md', 'w') as f:
        json.dump(data, f)

# main agent periodically scans knowledge base
import os
import json

def update_knowledge_base():
    knowledge_base = 'knowledge/bmad/README.md'
    if os.path.exists(knowledge_base):
        with open(knowledge_base, 'r') as f:
            data = json.load(f)
            # store data in main agent's cache
            cache['bmad'] = data

# main agent recalls recently delivered content
def recall_recent_deliveries():
    if 'bmad' in cache:
        return cache['bmad']
    return None

Verification

To verify that the fix worked, test the following scenarios:

  • Run the bmad-daily cron job and verify that the main agent can recall the delivered content.
  • Ask the main agent questions about the delivered content and verify that it can provide accurate answers.

Extra Tips

  • Consider implementing a more robust caching mechanism, such as a Redis or Memcached store, to handle larger volumes of data.
  • Ensure that the knowledge base and cache are properly synchronized to avoid data inconsistencies.

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

Some awareness of content passing through — at minimum, main session should be able to recall "I sent something about BMad v4.30.1 this morning" even if it doesn't have full context.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING