From b2c7187b1bfbe8da03565cd3c8a0dfda68c7a27b Mon Sep 17 00:00:00 2001 From: Miguel Lezama Date: Tue, 27 Oct 2026 10:19:21 -0300 Subject: [PATCH] Claude agent: a slow turn no longer gets the PHP worker killed A WhatsApp turn that waited about 30 seconds on the bridge hit PHP's max_execution_time, which counts wall time on macOS. PHP-FPM killed the worker and the client got a bare 502 with no reply. Each bridge call now gets the bridge timeout plus room to save the session, when a limit is set. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01X1vFfLD2Rs76ijqLWqF1Sa --- includes/class-openclawp-claude-agent-runner.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/includes/class-openclawp-claude-agent-runner.php b/includes/class-openclawp-claude-agent-runner.php index 8894b54..46d88b7 100644 --- a/includes/class-openclawp-claude-agent-runner.php +++ b/includes/class-openclawp-claude-agent-runner.php @@ -439,6 +439,15 @@ private static function post( array $body ): array { ); } + // A turn can take longer than PHP's max_execution_time (30 s by + // default), and on macOS that limit counts wall time spent waiting on + // the bridge. PHP-FPM then kills the worker mid-request and the client + // gets a bare 502. Give each bridge call its own timeout plus room to + // save the session. CLI runs have no limit and keep none. + if ( (int) ini_get( 'max_execution_time' ) > 0 && function_exists( 'set_time_limit' ) ) { + set_time_limit( $settings['timeout'] + 30 ); + } + $response = wp_remote_post( $settings['url'] . '/v1/turn', array(