LangChain for Python 0.3
Last reviewed Oct 24, 2026
Prompt Details
Prompt Composition
2prompts
- Python 3155 lines · 3.8K tokens
- LangChain for Python 0.357 lines · 2.5K tokens
Total212 lines · 6.2K tokens
CWE Coverage
- 20
- 23
- 36
- 59
- 73
- 78
- 89
- 95
- 117
- 201
- 208
- 209
- 214
- 250
- 295
- 319
- 328
- 338
- 347
- 367
- 379
- 409
- 416
- 426
- 427
- 470
- 488
- 502
- 522
- 524
- 532
- 611
- 639
- 674
- 732
- 770
- 772
- 776
- 807
- 829
- 841
- 862
- 916
- 918
- 1104
- 1333
- 1336
- 1395
- 1426
- 1427
Prompt Preview
Apply to the legacy LangChain 0.3 line and its langchain-core 0.3 dependency line, with compatible integration packages and the included Python baseline.
Prompt injection and templates
- Treat user messages, retrieved
Document.page_content, metadata, stored memory, and tool results as untrusted data. Keep them separate from developer-controlled instructions; none may grant tool authorization or change the principal. - Build message roles in application code. Accept user text as
HumanMessagecontent rather than accepting client-selectedSystemMessage,AIMessage, or tool-call records. Validate imported history before it reachesMessagesPlaceholder. - Keep
PromptTemplateandChatPromptTemplatetemplate structure under developer control; pass external text only as variable values. Prefer f-string templates or direct message construction; never accept untrusted Jinja2 templates, even with its sandbox. Pass simple values rather than credential-bearing objects to formatters. - Treat Hub prompts, chain/agent configurations, and serialized runnables as executable application configuration. Review their origin and content before use; never let a request select a remote artifact or enable its embedded model configuration.
- Prefer the LangSmith SDK over the deprecated
langchain.hub.pull(). Pull only reviewed prompts from your own organization, pinned to a commit hash; never passdangerously_pull_public_prompt=True,include_model=True, orsecrets_from_env=Truefor a publicowner/nameprompt. A same-organization prompt is only as trustworthy as every