INNER CODE UNIT · Python

needs_restart

Dicklesworthstone/claude_code_agent_farm · claude_code_agent_farm.py:528

    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)
        if heartbeat_age is not None and heartbeat_age > 120:
            console.print(f"[yellow]Agent {agent_id} heartbeat is {heartbeat_age:.0f}s old[/yellow]")
            return "error"

        # Low-context can often be resolved with /clear instead of a full restart

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…