langchain - ✅(Solved) Fix Will langchain support create_agent with pimono-like loop in loop capability. [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#35452Fetched 2026-04-08 00:26:04
View on GitHub
Comments
1
Participants
2
Timeline
11
Reactions
0
Timeline (top)
labeled ×4referenced ×2commented ×1cross-referenced ×1

Fix Action

Fixed

PR fix notes

PR #35459: feat(langchain): add create_agent_tool and AgentSession for nested loops and time-travel

Description (problem / solution / changelog)

Summary

Implements loop-in-loop agent patterns and session management requested in #35452.

  • create_agent_tool: wraps a compiled agent graph as a BaseTool so an outer agent can delegate subtasks to an inner agent that runs its own complete tool-calling loop — the "loop in loop" pattern.
  • AgentSession: convenience wrapper for interrupt/resume workflows and checkpoint-based time-travel (branching from any historical state into a new session).

Both APIs are marked as experimental and exported from langchain.agents.

Areas requiring careful review

  • _AgentTool._run / _arun — runtime import of CallbackManagerForToolRun outside TYPE_CHECKING is intentional (pydantic resolves the _run signature at runtime).
  • AgentSession.resume() — uses None for node-level interrupts vs Command(resume=value) for interrupt() calls; this distinction matters.
  • AgentSession.branch() — copies state via update_state to a new thread; does not deep-copy message objects.

Test plan

  • 6 unit tests for create_agent_tool (basic, nested loop-in-loop, async, thread prefix, exports)
  • 19 unit tests for AgentSession (run with all input types, interrupt/resume, state inspection, history, branching, preserving original state, async variants, exports)
  • All 194 existing agent tests pass (zero regressions)

This contribution was developed with AI agent assistance.

Closes #35452

Changed files

  • libs/langchain_v1/langchain/agents/__init__.py (modified, +4/-0)
  • libs/langchain_v1/langchain/agents/session.py (added, +312/-0)
  • libs/langchain_v1/langchain/agents/tool.py (added, +148/-0)
  • libs/langchain_v1/tests/unit_tests/agents/test_agent_session.py (added, +250/-0)
  • libs/langchain_v1/tests/unit_tests/agents/test_create_agent_tool.py (added, +147/-0)
RAW_BUFFERClick to expand / collapse

Checked other resources

  • This is a feature request, not a bug report or usage question.
  • I added a clear and descriptive title that summarizes the feature request.
  • I used the GitHub search to find a similar feature request and didn't find it.
  • I checked the LangChain documentation and API reference to see if this feature already exists.
  • This is not related to the langchain-community package.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Feature Description

I would like langchain to support loop in loop react agent. Just like pi-mono-agent-core.

Use Case

This feature would help user to build loop-in-loop agent pattern which can support 'interrupt', 'append' actions like pi-mono-agent-core while agent is running. Furthermore, we can also provide time travel base on session tree.

Proposed Solution

No response

Alternatives Considered

No response

Additional Context

No response

extent analysis

Solution Plan

Feature Support for Loop in Loop React Agent

Step 1: Implement Loop in Loop React Agent Support

  • Create a new class LoopInLoopAgent that extends ReactAgent.
  • Implement the interrupt and append actions as described in the use case.
  • Use a session tree to store the agent's state and support time travel.

Step 2: Update LangChain Core

  • Modify the langchain-core package to include the new LoopInLoopAgent class.
  • Update the langchain-core API reference to document the new feature.

Step 3: Test the New Feature

  • Write unit tests for the LoopInLoopAgent class to ensure it works correctly.
  • Test the feature with example use cases to verify its functionality.

Example Code

# langchain-core/loop_in_loop_agent.py
from langchain import ReactAgent

class LoopInLoopAgent(ReactAgent):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.session_tree = {}

    def interrupt(self, action):
        # Implement interrupt logic here
        pass

    def append(self, action):
        # Implement append logic here
        pass

    def time_travel(self, session_id):
        # Implement time travel logic here
        pass
# langchain-core/__init__.py
from .loop_in_loop_agent import LoopInLoopAgent

# Update the langchain-core API reference to document the new feature

Verification

  • Verify that the LoopInLoopAgent class is correctly implemented and works as expected.
  • Test the feature with example use cases to ensure its functionality.

Extra Tips

  • Make sure to update the langchain-core API reference to document the new feature.
  • Consider adding additional tests to ensure the feature works correctly in different scenarios.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING