The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
fix(core): correct misleading jinja2 sandboxing comment (#35183)
Yi Liu6a07b3acdadf
diff --git a/libs/core/langchain_core/prompts/string.py b/libs/core/langchain_core/prompts/string.pyindex a7e1263544..0e3a29d75e 100644--- a/libs/core/langchain_core/prompts/string.py+++ b/libs/core/langchain_core/prompts/string.py@@ -64,9 +64,11 @@ def jinja2_formatter(template: str, /, **kwargs: Any) -> str:)raise ImportError(msg)- # Use a restricted sandbox that blocks ALL attribute/method access- # Only simple variable lookups like {{variable}} are allowed- # Attribute access like {{variable.attr}} or {{variable.method()}} is blocked+ # Use Jinja2's SandboxedEnvironment which blocks access to dunder attributes+ # (e.g., __class__, __globals__) to prevent sandbox escapes.+ # Note: regular attribute access (e.g., {{obj.attr}}) and method calls are+ # still allowed. This is a best-effort measure — do not use with untrusted+ # templates.return SandboxedEnvironment().from_string(template).render(**kwargs)