Skip to content

[Bug]: iMessage + /reasoning on creates infinite agent feedback loop #25897

@rmarr

Description

@rmarr

Summary

When /reasoning on is explicitly enabled in an iMessage-connected session, reasoning/thinking blocks are delivered as Reasoning:-prefixed iMessages. These outbound messages are re-ingested by the iMessage provider as new inbound messages, triggering new agent runs and creating an infinite feedback loop that produces hundreds of runaway agent runs until force-killed.

This is a composite bug formed by two known issues firing simultaneously:

  1. Reasoning block delivery to iMessage — explicit /reasoning on still leaks thinking blocks as visible messages to iMessage. Reasoning/thinking blocks leaking into iMessage channel delivery #18667 reported this and was closed as superseded by PR fix(agents): suppress reasoning blocks from channel delivery #18935, but leakage persists on 2026.2.22-2 and 2026.2.23 when reasoning is explicitly enabled via /reasoning on.
    1. iMessage echo re-ingestion — outbound iMessages are picked up by the imsg polling bridge as new incoming messages (iMessage self-chat creates echo loop despite v2026.1.22 fixes #1649, still open).
      Why this is distinct from Reasoning/thinking blocks leaking into iMessage channel delivery #18667: That issue addresses only the reasoning leakage side. Even if fix(agents): suppress reasoning blocks from channel delivery #18935 fully resolves leakage, the underlying iMessage echo loop (iMessage self-chat creates echo loop despite v2026.1.22 fixes #1649) remains unfixed — meaning any future regression in reasoning suppression would immediately produce another runaway loop. This issue tracks the composite interaction and the need for defense-in-depth (dedup + suppression + rate limiting).

Steps to reproduce

  1. Connect an iMessage session via the imsg CLI bridge
  2. Enable /reasoning on in the session
  3. Send any message that triggers a model response
  4. Observe: the reasoning block is delivered as an iMessage, re-ingested as a new inbound message, triggering another agent run — looping indefinitely

The loop path:

/reasoning on → model produces thinking block
  → delivery pipeline formats as "Reasoning: ..." text
    → iMessage provider sends via imsg CLI
      → macOS stores message in chat DB
        → imsg polling picks it up as "new incoming message"
          → OpenClaw dispatches new agent run with "Reasoning: ..." as user input
            → model produces new thinking block → LOOP

Expected behavior

Reasoning/thinking blocks should not be delivered as visible messages to iMessage. Alternatively, outbound messages from the bot should be deduped and not re-ingested as inbound. At minimum, a rate limiter or circuit breaker should prevent hundreds of runaway agent runs.

Actual behavior

Hundreds of agent runs fire in rapid succession until the process is force-killed. Each iteration generates a new thinking block (the model sees "Reasoning: ..." as user input), produces a new response with reasoning, which gets delivered and re-ingested again. No rate limiting or circuit breaker exists to stop the loop.

OpenClaw version

2026.2.22-2, 2026.2.23

Operating system

macOS (iMessage requires macOS)

Install method

No response

Logs, screenshots, and evidence

Impact and severity

Affected: iMessage users with /reasoning on on 2026.2.22-2 and 2026.2.23
Severity: Critical (runaway agent loop, hundreds of runs before force-kill)
Frequency: 100% repro when both conditions met
Composite of #1649 (iMessage echo loop, still open) + reasoning leakage (#18667, closed by #18935 but not fully effective for explicit /reasoning on)

Additional information

Workaround: Do not enable /reasoning on in iMessage-connected sessions.

Suggested fixes:

  • Outbound message dedup filter: After sending via imsg, record message text + timestamp in a short-lived cache (~30s TTL). Skip processing on poll if match. Client-side equivalent of what Slack/Discord handle at platform level.
  • Suppress reasoning delivery for iMessage: Strip Reasoning: blocks when target is iMessage, matching what fix(telegram): filter reasoning segments when reasoningLevel is off #24518 does for Telegram.
  • Rate limiting / circuit breaker: Detect rapid-fire runs from same channel (>10 runs/minute) and pause. Would limit runaway loops regardless of cause.
  • Self-message detection: Broader fix for iMessage self-chat creates echo loop despite v2026.1.22 fixes #1649 — if sender matches bot's configured number or allowFrom entry, apply stricter dedup.

Related issues & PRs: #18667, #18935, #24290, #24335, #24518, #24626, #1649, #655, #659, #1031, #1080

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions