openclaw - 💡(How to fix) Fix Agent stuck in loop / wrong routing — `/new` fixes session (Telegram) [1 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#56845Fetched 2026-04-08 01:47:02
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
labeled ×2

This is a practical workaround / observation, not a confirmed bug report.

Root Cause

This is not obvious for beginners.
It may look like a script or configuration problem, even when everything is correct.

Hopefully this helps someone avoid unnecessary debugging.

Fix Action

Fix / Workaround

This is a practical workaround / observation, not a confirmed bug report.

RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

This is a practical workaround / observation, not a confirmed bug report.

Agent gets stuck in loop / wrong routing — /new fixes it (Telegram)

I want to share a practical finding that might help others.

Problem

Sometimes the agent:

  • stops using the correct skill
  • routes commands incorrectly
  • gets stuck in a loop or keeps “thinking” instead of executing

Even when:

  • scripts work correctly
  • paths are correct
  • check-skills.sh passes

What does NOT reliably fix it

openclaw gateway --force

This may restart the system, but the problem can still remain.


What DOES fix it

/new

Starting a new session resets the routing and fixes the issue reliably.


Suggested troubleshooting order

  1. Run: ~/.openclaw/workspace/scripts/check-skills.sh

  2. If scripts work:
    → do NOT debug scripts

  3. Use: /new


Observation

This seems to be related to session state getting stuck or corrupted, especially when using Telegram.


Why this matters

This is not obvious for beginners.
It may look like a script or configuration problem, even when everything is correct.

Hopefully this helps someone avoid unnecessary debugging.

Steps to reproduce

?

Expected behavior

Agent should continue to use correct skill routing without needing session reset

Actual behavior

Agent gets stuck in wrong routing or loop, and only /new fixes it

OpenClaw version

latest

Operating system

Ubuntu 24.04 (Intel NUC)

Install method

No response

Model

github gpt 4.1 and meny fallback models too

Provider / routing chain

OpenClaw local gateway + Telegram

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

Fix Plan

To address the issue of the agent getting stuck in a loop or wrong routing, we can implement a session reset mechanism. Since the /new command reliably fixes the issue, we can create a script to automatically restart the session when the agent gets stuck.

Example Code

We can create a Python script to monitor the agent's activity and restart the session if it gets stuck. Here's an example:

import time
import requests

def check_agent_status():
    # Replace with your OpenClaw API endpoint
    url = "http://localhost:8080/api/agent/status"
    response = requests.get(url)
    if response.status_code == 200:
        return response.json()["status"]
    else:
        return None

def restart_session():
    # Replace with your OpenClaw API endpoint
    url = "http://localhost:8080/api/session/restart"
    response = requests.post(url)
    if response.status_code == 200:
        print("Session restarted successfully")
    else:
        print("Failed to restart session")

def main():
    while True:
        status = check_agent_status()
        if status == "stuck" or status == "looping":
            restart_session()
        time.sleep(60)  # Check every 1 minute

if __name__ == "__main__":
    main()

Configuration Changes

To use this script, you'll need to:

  • Replace the url variables with your OpenClaw API endpoint
  • Configure the script to run continuously in the background
  • Set up a cron job to run the script every 1 minute

Temporary Workaround

If you don't have time to implement the script, you can use the /new command manually to restart the session when the agent gets stuck.

Verification

To verify that the fix worked, you can:

  • Monitor the agent's activity and check if it gets stuck or loops
  • Check the script's logs to see if the session was restarted successfully
  • Test the agent's functionality after the session restart to ensure it's working correctly

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

Agent should continue to use correct skill routing without needing session reset

Still need to ship something?

×6

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

Back to top recommendations

TRENDING