René's URL Explorer Experiment


Title: local_context | deepagents_code | LangChain Reference

Open Graph Title: local_context | deepagents_code

X Title: local_context | deepagents_code

Description: Python API reference for local_context in deepagents_code. Part of the LangChain ecosystem.

Open Graph Description: Python API reference for local_context in deepagents_code. Part of the LangChain ecosystem.

X Description: Python API reference for local_context in deepagents_code. Part of the LangChain ecosystem.

Opengraph URL: https://reference.langchain.com/python/deepagents-code/local_context

direct link

Domain: reference.langchain.com

og:imagehttps://reference.langchain.com/og/python/deepagents-code/local_context
og:image:width1200
og:image:height630
og:image:altlocal_context | deepagents_code
og:typearticle
twitter:cardsummary_large_image
twitter:imagehttps://reference.langchain.com/og/python/deepagents-code/local_context

Links:

LangChain Reference home pagehttps://reference.langchain.com/
GitHubhttps://github.com/langchain-ai
Main Docshttps://docs.langchain.com/oss/python/deepagents
Deep Agentshttps://reference.langchain.com/python/deepagents
LangChainhttps://reference.langchain.com/python/langchain/overview
LangGraphhttps://reference.langchain.com/python/langgraph/overview
Integrationshttps://reference.langchain.com/python/integrations/overview
LangSmithhttps://reference.langchain.com/python/langsmith
Deep Agents Codehttps://reference.langchain.com/python/deepagents-code
Deep Agents Codehttps://reference.langchain.com/python/deepagents-code
deepagents-codehttps://reference.langchain.com/python/deepagents-code
attributeloggerhttps://reference.langchain.com/python/deepagents-code/local_context/logger
attributeDETECT_CONTEXT_SCRIPThttps://reference.langchain.com/python/deepagents-code/local_context/DETECT_CONTEXT_SCRIPT
functionsanitize_control_charsNeutralize control characters and deceptive Unicode in untrusted text. Untrusted strings (MCP server errors, config-file contents, tool output) can carry ANSI escape sequences, other control characters, or invisible Unicode that corrupts the terminal, breaks out of a layout, or injects fake lines into logs and prompts. This first removes the invisible/bidi code points flagged by strip_dangerous_unicode, then replaces every remaining Unicode "Other" (control/format) character with a space.https://reference.langchain.com/python/deepagents-code/unicode_security/sanitize_control_chars
functionbuild_detect_scriptConcatenate all section functions into the full detection script. Independent sections run as parallel background jobs writing to temp files, then results are concatenated in the original display order. The header (CWD / IN_GIT) and project section (sets ROOT) run first because later sections depend on their variables.https://reference.langchain.com/python/deepagents-code/local_context/build_detect_script
classMCPServerInfoMetadata for a configured MCP server and its tools.https://reference.langchain.com/python/deepagents-code/mcp_tools/MCPServerInfo
classLocalContextStateState for local context middleware.https://reference.langchain.com/python/deepagents-code/local_context/LocalContextState
classLocalContextMiddlewareInject local context (git state, project structure, etc.) into the system prompt. Runs a bash detection script via backend.execute() on first interaction and again after each summarization event, stores the result in state, and appends it to the system prompt on every model call. Because the script runs inside the backend, it works for both local shells and remote sandboxes.https://reference.langchain.com/python/deepagents-code/local_context/LocalContextMiddleware
View source on GitHubhttps://github.com/langchain-ai/deepagents/blob/019900734024a7665fd65bd75235c6307d5da003/libs/code/deepagents_code/local_context.py

Viewport: width=device-width, initial-scale=1


URLs of crawlers that visited me.