LangChain for Python 1.3

Last reviewed Oct 28, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. Python 3155 lines · 3.8K tokens
  2. LangChain for Python 1.365 lines · 1.8K tokens
Total220 lines · 5.6K tokens

CWE Coverage

  • 20
  • 23
  • 36
  • 59
  • 78
  • 89
  • 95
  • 117
  • 208
  • 209
  • 214
  • 250
  • 295
  • 319
  • 328
  • 338
  • 347
  • 367
  • 379
  • 409
  • 416
  • 426
  • 427
  • 470
  • 488
  • 502
  • 522
  • 532
  • 611
  • 674
  • 732
  • 770
  • 772
  • 776
  • 807
  • 829
  • 841
  • 862
  • 916
  • 918
  • 1104
  • 1333
  • 1395
  • 1426
  • 1427

Prompt Preview

Apply the Python 3 baseline first. These rules cover LangChain for Python 1.3 agents, tools, middleware, structured output, retrieval, loaders, memory, runtime context, observability, and deployment.

Agents and runtime context

  • Construct agents, models, system prompts, tools, response formats, and middleware from trusted application configuration.
  • Keep user, retrieval, memory, and tool messages separate from authoritative instructions.
  • Pass authenticated identity and tenant context through a typed runtime context rather than prompt text.
  • Install ModelCallLimitMiddleware and ToolCallLimitMiddleware with finite per-run limits, then add independent time, token, retry, parallel-call, and spend bounds; call limits are not automatic.
  • Treat final messages and structured responses as untrusted until domain and sink validation succeeds.

Tools and model-selected actions

  • Register tools through a fixed allowlist with narrow schemas, minimal credentials, and bounded results.
  • Validate tool arguments independently and reauthorize each call against current principal, tenant, resource, and operation.
  • Require approval for privileged, irreversible, external, costly, or destructive actions.
  • Keep tool error handling from returning credentials, stack traces, internal queries, or excessive data to the model.
  • Isolate code, shell, browser, file, database, and network tools with independent capability and resource controls.
  • Make tool side effects idempotent or deduplicate them across retries and checkpoint resumes; a node containing interrupt() restarts from its