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
Domain: reference.langchain.com
| og:image | https://reference.langchain.com/og/python/deepagents-code/local_context |
| og:image:width | 1200 |
| og:image:height | 630 |
| og:image:alt | local_context | deepagents_code |
| og:type | article |
| twitter:card | summary_large_image |
| twitter:image | https://reference.langchain.com/og/python/deepagents-code/local_context |
Links:
| LangChain Reference home page | https://reference.langchain.com/ |
| GitHub | https://github.com/langchain-ai |
| Main Docs | https://docs.langchain.com/oss/python/deepagents |
| Deep Agents | https://reference.langchain.com/python/deepagents |
| LangChain | https://reference.langchain.com/python/langchain/overview |
| LangGraph | https://reference.langchain.com/python/langgraph/overview |
| Integrations | https://reference.langchain.com/python/integrations/overview |
| LangSmith | https://reference.langchain.com/python/langsmith |
| Deep Agents Code | https://reference.langchain.com/python/deepagents-code |
| Deep Agents Code | https://reference.langchain.com/python/deepagents-code |
| deepagents-code | https://reference.langchain.com/python/deepagents-code |
| attributelogger | https://reference.langchain.com/python/deepagents-code/local_context/logger |
| attributeDETECT_CONTEXT_SCRIPT | https://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 GitHub | https://github.com/langchain-ai/deepagents/blob/019900734024a7665fd65bd75235c6307d5da003/libs/code/deepagents_code/local_context.py |
Viewport: width=device-width, initial-scale=1