INNER CODE UNIT · Python
age
Dicklesworthstone/claude_code_agent_farm · claude_code_agent_farm.py:523
age = time.time() - mtime
return age
except Exception:
return None
def needs_restart(self, agent_id: int) -> Optional[str]:
"""Determine if an agent needs to be restarted and why
Returns:
None - no restart needed
'context' - context nearly exhausted, use /clear
'error' - encountered errors or heartbeat stalled, full restart
'idle' - idle for too long, full restart
"""
agent = self.agents[agent_id]
# Stalled heartbeat indicates the pane is likely hung
heartbeat_age = self._check_heartbeat_age(agent_id)