Skip to content

Commit bfef1a8

Browse files
sjarmakclaude
andcommitted
Fix OpenHands jupyter crash: monkey-patch CodeActAgent.sandbox_plugins
The [sandbox] plugins TOML config doesn't exist in OH v1.4.0 (crashes with pydantic extra_forbidden). The [core] enable_jupyter also has no effect on plugin loading. The real control is CodeActAgent.sandbox_plugins which is a property that checks self.config.enable_jupyter. Fix: inject a monkey-patch into oh_main_wrapper.py that overrides the sandbox_plugins property to filter out JupyterRequirement before OpenHands starts the LocalRuntime action execution server. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cd21a94 commit bfef1a8

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

agents/harnesses/openhands/agent.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ def create_run_agent_commands(self, instruction: str):
136136
else:
137137
env.pop("PYTHONPATH", None)
138138
env["PYTHONSAFEPATH"] = "1"
139-
# Disable jupyter at every config level to prevent LocalRuntime
140-
# from starting jupyter-kernelgateway (crashes in Daytona).
141-
env["SANDBOX_PLUGINS"] = "agent_skills" # excludes jupyter plugin
139+
# Hint to OpenHands config to disable jupyter/browsing.
140+
# The real fix is the monkey-patch in oh_main_wrapper.py that
141+
# removes JupyterRequirement from CodeActAgent.sandbox_plugins.
142142
env["ENABLE_JUPYTER"] = "false"
143143
env["ENABLE_BROWSING"] = "false"
144144
env["AGENT_ENABLE_JUPYTER"] = "false"
@@ -214,6 +214,18 @@ def create_run_agent_commands(self, instruction: str):
214214
" sys.meta_path.insert(0, _WorkspaceSafeFinder)",
215215
"",
216216
"_preload_site_package('pandas')",
217+
"",
218+
"# Monkey-patch CodeActAgent to exclude the jupyter plugin.",
219+
"# OpenHands v1.4.0 hardcodes JupyterRequirement in sandbox_plugins",
220+
"# and the jupyter-kernelgateway cannot bind inside Daytona sandboxes.",
221+
"import openhands.agenthub.codeact_agent.codeact_agent as _ca_mod",
222+
"from openhands.runtime.plugins import AgentSkillsRequirement",
223+
"_orig_plugins = _ca_mod.CodeActAgent.sandbox_plugins.fget",
224+
"@property",
225+
"def _no_jupyter_plugins(self):",
226+
" return [p for p in _orig_plugins(self) if p.name != 'jupyter']",
227+
"_ca_mod.CodeActAgent.sandbox_plugins = _no_jupyter_plugins",
228+
"",
217229
"runpy.run_module('openhands.core.main', run_name='__main__')",
218230
])
219231

@@ -303,14 +315,6 @@ def _build_config_toml(self, mcp_url: str | None = None) -> str:
303315
"enable_jupyter = false",
304316
"enable_browsing = false",
305317
"",
306-
# The sandbox plugins list controls what LocalRuntime passes to
307-
# --plugins on the action_execution_server command line. The
308-
# default is ["agent_skills", "jupyter"]. Excluding "jupyter"
309-
# prevents the jupyter-kernelgateway from starting — it cannot
310-
# bind inside Daytona sandboxes and crashes with RetryError.
311-
"[sandbox]",
312-
'plugins = ["agent_skills"]',
313-
"",
314318
"[agent]",
315319
f"enable_mcp = {'true' if mcp_url else 'false'}",
316320
"enable_jupyter = false",

0 commit comments

Comments
 (0)