openclaw - 💡(How to fix) Fix Feature Request: Cron Job Message Context Preservation [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#51430Fetched 2026-04-08 01:11:21
View on GitHub
Comments
2
Participants
3
Timeline
3
Reactions
0
Timeline (top)
commented ×2subscribed ×1

Error Message

  • Guess the context (error-prone)

Code Example

基于本周记忆文件,以下是反馈:

你有一个"过度交付后静默"的模式...
建议:每次大交付后写"发布后3个待验证事项"...

---

可以的,按照这个建议执行

---

[Context] Cron job "每周反馈提醒" (ID: xxx) sent message at 12:00:
---
<original message content>
---

---

[Thread: Cron job "每周反馈提醒"]
Cron (12:00): <original message>
User (12:27): 可以的,按照这个建议执行
RAW_BUFFERClick to expand / collapse

Feature Request: Cron Job Message Context Preservation

Problem Statement

When a cron job sends a message to the user, the agent (AI assistant) cannot see the original message content in the session context. This creates a context gap when the user replies to the cron job with references like "execute this suggestion" or "按照建议执行".

Current Behavior

  1. Cron job sends message to user at 12:00
  2. User reads the message (visible only to user)
  3. User replies at 12:27: "可以的,按照这个建议执行"
  4. Agent receives the reply but has no access to the cron job message
  5. Agent must either:
    • Guess the context (error-prone)
    • Ask for clarification (adds friction)
    • Query cron history (performance overhead, still ambiguous)

Real Example

Cron job message (invisible to agent):

基于本周记忆文件,以下是反馈:

你有一个"过度交付后静默"的模式...
建议:每次大交付后写"发布后3个待验证事项"...

User reply:

可以的,按照这个建议执行

Agent's dilemma: Which "suggestion"? What action to take?

Proposed Solution

Option A: Inject Cron Message into Session Context (Preferred)

When a cron job sends a message, automatically inject a system/context message into the agent's session:

[Context] Cron job "每周反馈提醒" (ID: xxx) sent message at 12:00:
---
<original message content>
---

This message appears in the agent's context window as part of the conversation history, even though it was generated by the cron system.

Option B: Automatic Context Retrieval

When agent receives a message with ambiguous references ("this", "that", "建议"), the system could:

  1. Check recent cron jobs (last 24h)
  2. Inject relevant cron message content into context
  3. Mark it as [Context from cron job xxx]

Option C: Reply Threading

Link user replies to their triggering cron messages, similar to how message threading works in chat platforms. The agent would see:

[Thread: Cron job "每周反馈提醒"]
Cron (12:00): <original message>
User (12:27): 可以的,按照这个建议执行

Benefits

BenefitDescription
Natural conversationUsers don't need to explicitly restate context
Reduced errorsAgent doesn't hallucinate missing context
Better UXNo need for "which suggestion?" clarifications
PerformanceNo need for runtime cron history queries

Technical Considerations

  1. Storage: Where to store the mapping between cron runs and session contexts?
  2. Privacy: Should all cron messages be visible to agents, or only specific types?
  3. Multi-session: How to handle cron jobs that deliver to multiple sessions?
  4. Retention: How long to keep cron messages in agent context?

Related Commands

Currently, openclaw cron runs --id <job-id> can retrieve historical cron messages, but:

  • Agent doesn't know which job ID to query
  • Requires additional API calls
  • Doesn't solve the association problem

Request

Please consider implementing Option A (inject cron message into session context) as it:

  • Is the most straightforward solution
  • Maintains conversation coherence
  • Requires minimal user behavior change
  • Aligns with how other messaging systems handle bot-to-user communication

Environment:

  • OpenClaw version: 2026.3.8
  • Use case: AI assistant with scheduled check-ins and feedback loops

extent analysis

Fix Plan

To implement Option A, inject cron message into session context, follow these steps:

  • Step 1: Modify Cron Job Code Update the cron job code to include a function that injects the cron message into the session context. This can be achieved by adding a new API call to the existing cron job code.
  • Step 2: Create API Endpoint Create a new API endpoint that accepts the cron message and session ID as parameters. This endpoint will be responsible for injecting the cron message into the session context.
  • Step 3: Update Session Context Update the session context to include the injected cron message. This can be done by adding a new message type to the session context, such as a "system" orcontext message.

Example code snippet in Python:

import requests

# Step 1: Modify Cron Job Code
def send_cron_message(message, session_id):
    # Send message to user
    user_message = send_message_to_user(message)
    
    # Inject cron message into session context
    inject_cron_message_into_context(message, session_id)

# Step 2: Create API Endpoint
def inject_cron_message_into_context(message, session_id):
    api_endpoint = "https://example.com/api/inject-cron-message"
    payload = {
        "message": message,
        "session_id": session_id
    }
    response = requests.post(api_endpoint, json=payload)
    if response.status_code == 200:
        print("Cron message injected into session context successfully")
    else:
        print("Error injecting cron message into session context")

# Step 3: Update Session Context
def update_session_context(session_id, message):
    # Update session context to include injected cron message
    session_context = get_session_context(session_id)
    session_context["messages"].append({
        "type": "system",
        "content": message
    })
    update_session_context_in_database(session_id, session_context)

Verification

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

  • Send a cron message to a user and verify that the message is injected into the session context.
  • Verify that the agent can see the injected cron message in the session context.
  • Test user replies to the cron message and verify that the agent can understand the context correctly.

Extra Tips

  • Ensure that the cron message is properly formatted and includes all necessary information for the agent to understand the context.
  • Consider implementing a retention policy for cron messages in the session context to prevent clutter and improve performance.
  • Test the fix thoroughly to ensure that it works correctly in all scenarios and edge cases.

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…

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 Feature Request: Cron Job Message Context Preservation [2 comments, 3 participants]