Claude Code Claude Opus 4.6 commited on
Commit
5f011da
·
1 Parent(s): 1a6aa83

Claude Code: Fix brain_minimal to explicitly clear error field on status updates

Browse files

The _update_status_file() method now explicitly sets error: None and
preserves startup_checks field. This ensures stale errors don't persist
in the status file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

openclaw/.openclaw/agents/brain_minimal.py CHANGED
@@ -222,29 +222,34 @@ class AgentStateMachine:
222
 
223
  def _update_status_file(self):
224
  """Update cain_status.json with current state and timestamp."""
225
- # Read existing status file to preserve stage and a2a fields
226
  existing_stage = None
227
  existing_a2a = None
 
228
  try:
229
  if self._status_file.exists():
230
  with open(self._status_file, "r") as f:
231
  existing_data = json.load(f)
232
  existing_stage = existing_data.get("stage")
233
  existing_a2a = existing_data.get("a2a")
 
234
  except Exception:
235
- pass # If read fails, we'll create new status without stage/a2a
236
 
237
  status_data = {
238
  "current_state": self._state.value,
239
  "last_updated": datetime.utcnow().isoformat() + "+00:00",
240
- "agent": self._agent_name
 
241
  }
242
 
243
- # Preserve stage and a2a fields if they existed
244
  if existing_stage:
245
  status_data["stage"] = existing_stage
246
  if existing_a2a:
247
  status_data["a2a"] = existing_a2a
 
 
248
 
249
  try:
250
  with open(self._status_file, "w") as f:
 
222
 
223
  def _update_status_file(self):
224
  """Update cain_status.json with current state and timestamp."""
225
+ # Read existing status file to preserve stage, a2a, and startup_checks fields
226
  existing_stage = None
227
  existing_a2a = None
228
+ existing_startup_checks = None
229
  try:
230
  if self._status_file.exists():
231
  with open(self._status_file, "r") as f:
232
  existing_data = json.load(f)
233
  existing_stage = existing_data.get("stage")
234
  existing_a2a = existing_data.get("a2a")
235
+ existing_startup_checks = existing_data.get("startup_checks")
236
  except Exception:
237
+ pass # If read fails, we'll create new status without preserved fields
238
 
239
  status_data = {
240
  "current_state": self._state.value,
241
  "last_updated": datetime.utcnow().isoformat() + "+00:00",
242
+ "agent": self._agent_name,
243
+ "error": None # Explicitly clear error when state machine updates
244
  }
245
 
246
+ # Preserve stage, a2a, and startup_checks fields if they existed
247
  if existing_stage:
248
  status_data["stage"] = existing_stage
249
  if existing_a2a:
250
  status_data["a2a"] = existing_a2a
251
+ if existing_startup_checks:
252
+ status_data["startup_checks"] = existing_startup_checks
253
 
254
  try:
255
  with open(self._status_file, "w") as f: