Skip to content

Commit 37f0448

Browse files
sjarmakclaude
andcommitted
Skip chown -R /workspace during OH action server startup
init_user_and_working_directory() runs chown -R on /workspace synchronously in the FastAPI lifespan, BEFORE the server binds its port. On large repos (firefox ~100K files), this exceeds the 120s client connect timeout, causing ConnectError and the agent never running. Since we already run as root (uid 0) inside Harbor containers, the chown is a no-op anyway. Monkey-patch it out in the wrapper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e9d9ced commit 37f0448

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

agents/harnesses/openhands/agent.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,19 @@ def create_run_agent_commands(self, instruction: str):
222222
"import openhands.agenthub.codeact_agent.codeact_agent as _ca_mod",
223223
"_ca_mod.CodeActAgent.sandbox_plugins = []",
224224
"",
225+
"# Skip init_user_and_working_directory's chown -R on /workspace.",
226+
"# We already run as root (uid 0) inside Harbor containers, so the",
227+
"# recursive chown is a no-op that takes >120s on large repos (firefox,",
228+
"# linux, etc.), causing the action_execution_server to miss its startup",
229+
"# deadline and the OH client to throw ConnectError.",
230+
"import openhands.runtime.utils.runtime_init as _ri_mod",
231+
"def _noop_init_user(**kw): return kw.get('user_id', 0)",
232+
"_ri_mod.init_user_and_working_directory = _noop_init_user",
233+
"# Also patch the server module's imported reference",
234+
"import openhands.runtime.action_execution_server as _aes_mod",
235+
"if hasattr(_aes_mod, 'init_user_and_working_directory'):",
236+
" _aes_mod.init_user_and_working_directory = _noop_init_user",
237+
"",
225238
"runpy.run_module('openhands.core.main', run_name='__main__')",
226239
])
227240

0 commit comments

Comments
 (0)