Skip to content

Conversation

@aroun-coumar
Copy link

Closes #33684

Problem

When using ShellToolMiddleware with human-in-the-loop (HIL) interrupts, the persistent shell session is lost on resume:

  • _SessionResources was stored in agent state → fails msgpack serialization
  • No mechanism to restore the shell session after interruption
  • Result: shell tool fails or starts a new session on resume

Fix

This PR fully resolves the HIL session loss by:

  • Caching the shell session in the middleware instance (_session, _tempdir)
  • Saving only serializable config to checkpoint.metadata:
    "shell_session": {
        "workspace": "...",
        "command": [...],
        "env": {...},
        "policy": {...}
    }

Restoring session via a new restore_shell graph node when resume_from == "interrupt"
Adding to_dict() / from_dict() to BaseExecutionPolicy for safe serialization

@github-actions github-actions bot added langchain Related to the package `langchain` v1 Issue specific to LangChain 1.0 fix labels Oct 29, 2025
@aroun-coumar aroun-coumar changed the title fix(agents): ShellToolMiddleware session lost on HIL resume fix(langchain_v1): ShellToolMiddleware session lost on HIL resume Oct 29, 2025
@github-actions github-actions bot added fix and removed fix labels Oct 29, 2025
@aroun-coumar
Copy link
Author

@ccurme I have made changes for HIL issue in ShellToolMiddleware, this change doesnt break anything

Please review it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix langchain Related to the package `langchain` v1 Issue specific to LangChain 1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

langchain: ShellToolMiddleware breaks with HIL

1 participant