Spaces:
Running
Running
Claude Code commited on
Commit ·
2943b6a
1
Parent(s): 10a592e
god: Fix task blocking - allow faster handoff when CC stuck
Browse files- Lower auto-terminate thresholds: 45s for 0-push (was 90s), 40s for low-push (was 60s)
- Lower turns-since-push threshold: 5 turns (was 10)
- Lower warning threshold: tell agents to terminate at 50s (was 120s)
- This allows ANY agent to take over stuck tasks faster, preventing discussion loops
scripts/conversation-loop.py
CHANGED
|
@@ -1663,13 +1663,14 @@ def parse_and_execute_turn(raw_text, ctx):
|
|
| 1663 |
elif child_state["stage"] in ("BUILDING", "RESTARTING", "APP_STARTING"):
|
| 1664 |
results.append({"action": "task", "result": f"BLOCKED: Cain is {child_state['stage']}. Wait for it to finish."})
|
| 1665 |
elif cc_status["running"]:
|
| 1666 |
-
# LOW-PUSH-FREQUENCY EMERGENCY: If push frequency is critically low and task has been running
|
| 1667 |
# This prevents all-talk-no-action when agents get stuck after 1 push
|
|
|
|
| 1668 |
global _push_count, _turns_since_last_push, _push_count_this_task
|
| 1669 |
task_elapsed = time.time() - cc_status["started"] if cc_status["running"] else 0
|
| 1670 |
-
# Auto-terminate if: (0 pushes in this task and
|
| 1671 |
-
should_terminate = (_push_count_this_task == 0 and task_elapsed >
|
| 1672 |
-
(_push_count_this_task <= 1 and _turns_since_last_push >=
|
| 1673 |
if should_terminate:
|
| 1674 |
# Auto-terminate the stuck task and allow the new one
|
| 1675 |
print(f"[LOW-PUSH-FREQ] Auto-terminating stuck task ({task_elapsed:.0f}s old, {_push_count_this_task} pushes this task, {_turns_since_last_push} turns since last push) to allow task handoff.")
|
|
@@ -1959,7 +1960,7 @@ def build_turn_message(speaker, other, ctx):
|
|
| 1959 |
else:
|
| 1960 |
parts.append(f"\n🚨 URGENT: Push frequency is TOO LOW ({_push_count_this_task} pushes THIS TASK, {_turns_since_last_push} turns since last push).")
|
| 1961 |
parts.append(f"PLAN your next [TASK] NOW. Be SPECIFIC: file paths, function names, exact changes.")
|
| 1962 |
-
elif cc_elapsed >
|
| 1963 |
parts.append(f"\n⚠️ WARNING: CC has been running for {cc_elapsed}s! If output is stale, use [ACTION: terminate_cc] to kill it and re-assign the task.")
|
| 1964 |
elif _push_count > 0 and _turns_since_last_push >= 5:
|
| 1965 |
parts.append(f"\n🚨 URGENT: Claude Code is WORKING, but it's been {_turns_since_last_push} turns since last push.")
|
|
|
|
| 1663 |
elif child_state["stage"] in ("BUILDING", "RESTARTING", "APP_STARTING"):
|
| 1664 |
results.append({"action": "task", "result": f"BLOCKED: Cain is {child_state['stage']}. Wait for it to finish."})
|
| 1665 |
elif cc_status["running"]:
|
| 1666 |
+
# LOW-PUSH-FREQUENCY EMERGENCY: If push frequency is critically low and task has been running 40s+, allow task handoff
|
| 1667 |
# This prevents all-talk-no-action when agents get stuck after 1 push
|
| 1668 |
+
# Allow ANY agent to terminate stuck tasks, not just the task owner
|
| 1669 |
global _push_count, _turns_since_last_push, _push_count_this_task
|
| 1670 |
task_elapsed = time.time() - cc_status["started"] if cc_status["running"] else 0
|
| 1671 |
+
# Auto-terminate if: (0 pushes in this task and 45s elapsed) OR (<=1 push and 5+ turns since last push and 40s elapsed)
|
| 1672 |
+
should_terminate = (_push_count_this_task == 0 and task_elapsed > 45) or \
|
| 1673 |
+
(_push_count_this_task <= 1 and _turns_since_last_push >= 5 and task_elapsed > 40)
|
| 1674 |
if should_terminate:
|
| 1675 |
# Auto-terminate the stuck task and allow the new one
|
| 1676 |
print(f"[LOW-PUSH-FREQ] Auto-terminating stuck task ({task_elapsed:.0f}s old, {_push_count_this_task} pushes this task, {_turns_since_last_push} turns since last push) to allow task handoff.")
|
|
|
|
| 1960 |
else:
|
| 1961 |
parts.append(f"\n🚨 URGENT: Push frequency is TOO LOW ({_push_count_this_task} pushes THIS TASK, {_turns_since_last_push} turns since last push).")
|
| 1962 |
parts.append(f"PLAN your next [TASK] NOW. Be SPECIFIC: file paths, function names, exact changes.")
|
| 1963 |
+
elif cc_elapsed > 50:
|
| 1964 |
parts.append(f"\n⚠️ WARNING: CC has been running for {cc_elapsed}s! If output is stale, use [ACTION: terminate_cc] to kill it and re-assign the task.")
|
| 1965 |
elif _push_count > 0 and _turns_since_last_push >= 5:
|
| 1966 |
parts.append(f"\n🚨 URGENT: Claude Code is WORKING, but it's been {_turns_since_last_push} turns since last push.")
|