NVIDIA / NVIDIA/NemoClaw

[dcode] Managed sessions leak supervisor and LangGraph processes after exit

Open
#6,720 3 comments 0 reactions 1 assignee Claimed by @jyaunches View on GitHub
area: sandbox integration: dcode needs: unblock
Dominant language
TypeScript
Stars
22.5k
Forks
3.1k
Avg merge
1d 1h
Merged PRs (30d)
715

Description

### Description

Managed Deep Agents Code sessions leave their full process tree running after the caller exits or disconnects. This reproduces with a direct headless `dcode` invocation outside the web UI, and repeated embedded-terminal sessions add additional retained process trees.

The sandbox itself should remain ready, but processes associated with a completed session should be terminated and reaped by `dcode-session-supervisor.py`.

### Tested version

```text
nemoclaw v0.0.80-20-gdfee1160a
NemoClaw SHA: dfee1160a1f1c1709395836503a8c3ee6eb10424
OpenShell: 0.0.72
Deep Agents Code: 0.1.34
```

This SHA includes the managed session lifecycle work from #6680.

### UI-independent reproduction

With a configured and ready `deepagents-code` sandbox, run:

```bash
openshell sandbox exec --name deepagents-code -- \
dcode -n 'Reply with exactly one word: PONG' \
--json --max-turns 1 --timeout 120
```

The command returns exit zero, produces `PONG`, and reports OpenRouter usage successfully. After it returns, inspect the process tree:

```bash
pgrep -af 'dcode-session-supervisor.py'
pgrep -af 'deepagents_code --sandbox none'
pgrep -af 'langgraph_cli dev'
```

### Observed behavior

One complete session tree remains alive after the headless command has returned:

```text
dcode-session-supervisor.py
└── python -m deepagents_code --sandbox none --no-mcp
└── python -m langgraph_cli dev ...
```

The same behavior occurs through the embedded terminal. In one acceptance run, process counts grew as follows:

```text
After direct headless inference: 1 retained session tree
After terminal disconnect while active: 2 retained session trees
After response + explicit modal close: 3 retained session trees
```

The three supervisor, Deep Agents Code, and LangGraph processes were still alive more than 40 seconds after the final explicit close.

Because the direct headless invocation leaks without involving the dashboard or its WebSocket, the web UI is a trigger but not the sole cause.

### Expected behavior

- A completed headless invocation terminates and reaps all descendants associated with that invocation.
- Disconnecting an interactive terminal terminates and reaps that terminal's descendants.
- Closing an interactive terminal after a completed response terminates and reaps that terminal's descendants.
- The `deepagents-code` sandbox remains `Ready` and can start a fresh session.
- Repeated sessions return process counts to the previous baseline rather than accumulating supervisors and LangGraph servers.

### Impact

Repeated use accumulates background model servers, memory usage, listening ports, and stale session state. Long-lived launchables can eventually become unreliable or exhaust resources.

### Likely area

- `agents/langchain-deepagents-code/dcode-session-supervisor.py`
- `agents/langchain-deepagents-code/dcode-launcher.sh`
- `agents/langchain-deepagents-code/dcode-wrapper.sh`

The embedded terminal close path may warrant a downstream follow-up, but the headless reproduction should be fixed independently of UI lifecycle behavior.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.