Skip to content

ShellToolMiddleware.before_agent task error on Windows #1503

@klonuo

Description

@klonuo

I wanted to try v3 so installed current jupyter_ai-3.0.0b9-py3-none-any.whl with jupyterlab 4.5.0

However when I try to use chat I get error:

I 2025-11-20 13:38:30.359 LabApp] Build is up to date
[W 2025-11-20 13:38:58.770 ServerApp] 404 GET /api/contents/test.chat?content=0&hash=0&1763642338755 (96750df0d3564d908946692501e3c29e@::1) 2.01ms referer=http://localhost:8888/lab
[W 2025-11-20 13:38:58.803 ServerApp] 404 GET /api/contents/test.chat?content=0&hash=0&1763642338755 (::1): No such file or directory: test.chat
[I 2025-11-20 13:38:58.806 ServerApp] Creating new file in
[I 2025-11-20 13:38:59.108 ServerDocsApp] Initializing room 'text:chat:89f8dd78-c26d-4b24-9a9e-f5b743ba35f2'.
[I 2025-11-20 13:38:59.117 ServerDocsApp] Room 'text:chat:89f8dd78-c26d-4b24-9a9e-f5b743ba35f2' initialized.
[I 2025-11-20 13:38:59.120 ServerDocsApp] Loading content for room ID 'text:chat:89f8dd78-c26d-4b24-9a9e-f5b743ba35f2', found at path: 'test.chat'.
[I 2025-11-20 13:38:59.123 RouterExtension] New chat room detected: text:chat:89f8dd78-c26d-4b24-9a9e-f5b743ba35f2
[I 2025-11-20 13:38:59.132 ServerDocsApp] Loaded content for room ID 'text:chat:89f8dd78-c26d-4b24-9a9e-f5b743ba35f2'.
[I 2025-11-20 13:38:59.136 RouterExtension] Connected chat text:chat:89f8dd78-c26d-4b24-9a9e-f5b743ba35f2 to router
[I 2025-11-20 13:38:59.137 RouterExtension] Registered slash command callback for pattern: refresh-personas
[I 2025-11-20 13:38:59.139 JaiChatCommandsExtension] Attached router observer.
[I 2025-11-20 13:38:59.141 PersonaManagerExtension] Router detected new chat room, initializing persona manager: text:chat:89f8dd78-c26d-4b24-9a9e-f5b743ba35f2
[I 2025-11-20 13:38:59.892 PersonaManagerExtension] Found 1 entry points under 'jupyter_ai.personas'.
[I 2025-11-20 13:38:59.893 PersonaManagerExtension] PENDING: Loading AI persona classes from entry points...
[I 2025-11-20 13:38:59.893 PersonaManagerExtension]   - Loaded AI persona class 'JupyternautPersona' from 'jupyter_ai_jupyternaut.jupyternaut.jupyternaut' using entry point 'jupyternaut'.
[I 2025-11-20 13:38:59.894 PersonaManagerExtension] SUCCESS: Loaded 1 AI persona classes from entry points. Time elapsed: 1ms.
[I 2025-11-20 13:38:59.901 PersonaManagerExtension] No .jupyter directory found for loading local personas.
[I 2025-11-20 13:38:59.902 PersonaManagerExtension] Persona classes loaded in chat 'text:chat:89f8dd78-c26d-4b24-9a9e-f5b743ba35f2'.
[I 2025-11-20 13:38:59.902 PersonaManagerExtension] PENDING: Initializing AI personas for chat room 'ac19d5b0-855a-4824-91e0-a17228465311'...
[I 2025-11-20 13:38:59.906 PersonaManagerExtension]   - Initialized persona 'Jupyternaut' (ID: 'jupyter-ai-personas::jupyter_ai_jupyternaut::JupyternautPersona').
[I 2025-11-20 13:38:59.907 PersonaManagerExtension] SUCCESS: Initialized 1 AI personas for chat room 'ac19d5b0-855a-4824-91e0-a17228465311'. Time elapsed: 4ms.
[I 2025-11-20 13:38:59.907 PersonaManagerExtension] Personas initialized in chat 'text:chat:89f8dd78-c26d-4b24-9a9e-f5b743ba35f2'.
[W 2025-11-20 13:38:59.908 PersonaManagerExtension] No default persona is set in chat 'text:chat:89f8dd78-c26d-4b24-9a9e-f5b743ba35f2'.
[I 2025-11-20 13:38:59.909 RouterExtension] Registered message callback
[I 2025-11-20 13:39:00.487 ServerDocsApp] Reseting last_modified to 2025-11-20 12:39:00.470013+00:00
Starting shell session failed; cleaning up resources.
Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\langchain\agents\middleware\shell_tool.py", line 554, in _create_resources
    session.start()
  File "C:\Python312\Lib\site-packages\langchain\agents\middleware\shell_tool.py", line 141, in start
    self._process = self._policy.spawn(
                    ^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\langchain\agents\middleware\_execution.py", line 136, in spawn
    process = _launch_subprocess(
              ^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\langchain\agents\middleware\_execution.py", line 33, in _launch_subprocess
    return subprocess.Popen(  # noqa: S603
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Python312\Lib\subprocess.py", line 1538, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
[E 2025-11-20 13:39:10.382 PersonaManagerExtension] Persona 'Jupyternaut' encountered an exception printed below when attempting to stream output.
[E 2025-11-20 13:39:10.382 PersonaManagerExtension] [WinError 2] The system cannot find the file specified
    Traceback (most recent call last):
      File "C:\Python312\Lib\site-packages\jupyter_ai_persona_manager\base_persona.py", line 243, in stream_message
        async for chunk in reply_stream:
      File "C:\Python312\Lib\site-packages\jupyter_ai_jupyternaut\jupyternaut\jupyternaut.py", line 172, in create_aiter
        async for token, metadata in agent.astream(
      File "C:\Python312\Lib\site-packages\langgraph\pregel\main.py", line 2956, in astream
        async for _ in runner.atick(
      File "C:\Python312\Lib\site-packages\langgraph\pregel\_runner.py", line 410, in atick
        _panic_or_proceed(
      File "C:\Python312\Lib\site-packages\langgraph\pregel\_runner.py", line 520, in _panic_or_proceed
        raise exc
      File "C:\Python312\Lib\site-packages\langgraph\pregel\_retry.py", line 137, in arun_with_retry
        return await task.proc.ainvoke(task.input, config)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Python312\Lib\site-packages\langgraph\_internal\_runnable.py", line 705, in ainvoke
        input = await asyncio.create_task(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Python312\Lib\site-packages\langgraph\_internal\_runnable.py", line 473, in ainvoke
        ret = await self.afunc(*args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Python312\Lib\site-packages\langchain\agents\middleware\shell_tool.py", line 499, in abefore_agent
        return self.before_agent(state, runtime)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Python312\Lib\site-packages\langchain\agents\middleware\shell_tool.py", line 494, in before_agent
        resources = self._get_or_create_resources(state)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Python312\Lib\site-packages\langchain\agents\middleware\shell_tool.py", line 532, in _get_or_create_resources
        new_resources = self._create_resources()
                        ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Python312\Lib\site-packages\langchain\agents\middleware\shell_tool.py", line 554, in _create_resources
        session.start()
      File "C:\Python312\Lib\site-packages\langchain\agents\middleware\shell_tool.py", line 141, in start
        self._process = self._policy.spawn(
                        ^^^^^^^^^^^^^^^^^^^
      File "C:\Python312\Lib\site-packages\langchain\agents\middleware\_execution.py", line 136, in spawn
        process = _launch_subprocess(
                  ^^^^^^^^^^^^^^^^^^^
      File "C:\Python312\Lib\site-packages\langchain\agents\middleware\_execution.py", line 33, in _launch_subprocess
        return subprocess.Popen(  # noqa: S603
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Python312\Lib\subprocess.py", line 1026, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "C:\Python312\Lib\subprocess.py", line 1538, in _execute_child
        hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    FileNotFoundError: [WinError 2] The system cannot find the file specified
    During task with name 'ShellToolMiddleware.before_agent' and id '347460d0-cd36-15d1-3d14-b555184037fe'
[I 2025-11-20 13:39:10.640 ServerDocsApp] Reseting last_modified to 2025-11-20 12:39:10.627814+00:00

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBugs reported by users

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions