[PR #1295] refactor(cli): expand local context & implement via bash for sandbox support #1285

Open
opened 2026-02-16 09:18:37 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagents/pull/1295
Author: @vtrivedy
Created: 2/11/2026
Status: 🔄 Open

Base: mainHead: vivek/cli-middleware


📝 Commits (4)

  • 41ccad3 Add runtime detection to local context middleware
  • 962196e refactor(cli): rewrite local context detection as bash script via backend.execute()
  • 1223011 Fix ty type error in LocalContextMiddleware with protocol narrowing
  • ff92d3f refactor(cli): split local context bash script into testable section functions

📊 Changes

3 files changed (+782 additions, -728 deletions)

View changed files

📝 libs/cli/deepagents_cli/agent.py (+7 -4)
📝 libs/cli/deepagents_cli/local_context.py (+306 -514)
📝 libs/cli/tests/unit_tests/test_local_context.py (+469 -210)

📄 Description

  • LocalContextMiddleware: Adds runtime version detection (Python, Node) and git dirty file count to the environment context injected into agent conversations
  • LoopDetectionMiddleware: New proposal file (NOT wired in) that detects when the agent is stuck editing the same file repeatedly
    • Soft warning at 4 edits: appends a nudge to the tool output suggesting a different approach
    • Hard warning at 8 edits: injects a HumanMessage forcing the agent to stop and ask the user for help
    • Counters reset automatically on summarization (detected via message count drop) and on /clear or new threads (new middleware instance)

The loop detection middleware is ported from the Harbor benchmark harness where it ran across 445 TB2 trials, adapted for CLI's human-in-the-loop context.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagents/pull/1295 **Author:** [@vtrivedy](https://github.com/vtrivedy) **Created:** 2/11/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `vivek/cli-middleware` --- ### 📝 Commits (4) - [`41ccad3`](https://github.com/langchain-ai/deepagents/commit/41ccad3de72a105640b387447bde12289fa99cca) Add runtime detection to local context middleware - [`962196e`](https://github.com/langchain-ai/deepagents/commit/962196e4d9f052608f7952be30380df707d78ed3) refactor(cli): rewrite local context detection as bash script via backend.execute() - [`1223011`](https://github.com/langchain-ai/deepagents/commit/12230115f8ede4616db83d4cd2e2bce9c08a1ba5) Fix ty type error in LocalContextMiddleware with protocol narrowing - [`ff92d3f`](https://github.com/langchain-ai/deepagents/commit/ff92d3f7e0d2610fa744e5be504686cf95e0e9ed) refactor(cli): split local context bash script into testable section functions ### 📊 Changes **3 files changed** (+782 additions, -728 deletions) <details> <summary>View changed files</summary> 📝 `libs/cli/deepagents_cli/agent.py` (+7 -4) 📝 `libs/cli/deepagents_cli/local_context.py` (+306 -514) 📝 `libs/cli/tests/unit_tests/test_local_context.py` (+469 -210) </details> ### 📄 Description - **LocalContextMiddleware**: Adds runtime version detection (Python, Node) and git dirty file count to the environment context injected into agent conversations - **LoopDetectionMiddleware**: New proposal file (NOT wired in) that detects when the agent is stuck editing the same file repeatedly - Soft warning at 4 edits: appends a nudge to the tool output suggesting a different approach - Hard warning at 8 edits: injects a HumanMessage forcing the agent to stop and ask the user for help - Counters reset automatically on summarization (detected via message count drop) and on `/clear` or new threads (new middleware instance) The loop detection middleware is ported from the Harbor benchmark harness where it ran across 445 TB2 trials, adapted for CLI's human-in-the-loop context. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 09:18:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagents#1285