Spaces:
Runtime error
Runtime error
Claude Code commited on
Commit ·
0aa89f3
1
Parent(s): d66055d
god: Fix manual terminate+task blocking - allow immediate task reassignment
Browse files
scripts/conversation-loop.py
CHANGED
|
@@ -1650,12 +1650,16 @@ def parse_and_execute_turn(raw_text, ctx):
|
|
| 1650 |
task_match = re.search(r'\[TASK\](.*?)\[/TASK\]', raw_text, re.DOTALL)
|
| 1651 |
if task_match:
|
| 1652 |
task_desc = task_match.group(1).strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1653 |
# task_assigned is set to True ONLY when task is actually submitted, not when blocked
|
| 1654 |
if not task_desc:
|
| 1655 |
results.append({"action": "task", "result": "Empty task description."})
|
| 1656 |
elif child_state["stage"] in ("BUILDING", "RESTARTING", "APP_STARTING"):
|
| 1657 |
results.append({"action": "task", "result": f"BLOCKED: Cain is {child_state['stage']}. Wait for it to finish."})
|
| 1658 |
-
elif cc_status["running"]:
|
| 1659 |
# LOW-PUSH-FREQUENCY EMERGENCY: If push frequency is critically low and task has been running 60s+, allow task handoff
|
| 1660 |
# This prevents all-talk-no-action when agents get stuck after 1 push
|
| 1661 |
global _push_count, _turns_since_last_push, _push_count_this_task
|
|
@@ -1680,7 +1684,8 @@ def parse_and_execute_turn(raw_text, ctx):
|
|
| 1680 |
|
| 1681 |
# Task submission block - handles both normal flow and post-zero-push-termination flow
|
| 1682 |
# Only proceeds if not blocked above (results is empty or only contains termination notice)
|
| 1683 |
-
|
|
|
|
| 1684 |
# Check cooldown
|
| 1685 |
check_and_clear_cooldown()
|
| 1686 |
if last_rebuild_trigger_at > 0:
|
|
|
|
| 1650 |
task_match = re.search(r'\[TASK\](.*?)\[/TASK\]', raw_text, re.DOTALL)
|
| 1651 |
if task_match:
|
| 1652 |
task_desc = task_match.group(1).strip()
|
| 1653 |
+
# Check if this message also contains [ACTION: terminate_cc]
|
| 1654 |
+
# If so, the termination will be processed before task submission (below),
|
| 1655 |
+
# so we should allow this task to proceed even if cc_status["running"] is currently True.
|
| 1656 |
+
has_manual_terminate = re.search(r'\[ACTION:\s*terminate_cc\]', raw_text)
|
| 1657 |
# task_assigned is set to True ONLY when task is actually submitted, not when blocked
|
| 1658 |
if not task_desc:
|
| 1659 |
results.append({"action": "task", "result": "Empty task description."})
|
| 1660 |
elif child_state["stage"] in ("BUILDING", "RESTARTING", "APP_STARTING"):
|
| 1661 |
results.append({"action": "task", "result": f"BLOCKED: Cain is {child_state['stage']}. Wait for it to finish."})
|
| 1662 |
+
elif cc_status["running"] and not has_manual_terminate:
|
| 1663 |
# LOW-PUSH-FREQUENCY EMERGENCY: If push frequency is critically low and task has been running 60s+, allow task handoff
|
| 1664 |
# This prevents all-talk-no-action when agents get stuck after 1 push
|
| 1665 |
global _push_count, _turns_since_last_push, _push_count_this_task
|
|
|
|
| 1684 |
|
| 1685 |
# Task submission block - handles both normal flow and post-zero-push-termination flow
|
| 1686 |
# Only proceeds if not blocked above (results is empty or only contains termination notice)
|
| 1687 |
+
# Also allows submission if this message contains [ACTION: terminate_cc] (manual termination)
|
| 1688 |
+
if (not results or any("terminate_cc" in r.get("action", "") for r in results)) and (cc_status["running"] == False or has_manual_terminate):
|
| 1689 |
# Check cooldown
|
| 1690 |
check_and_clear_cooldown()
|
| 1691 |
if last_rebuild_trigger_at > 0:
|