DSPy 3.3.1

Last reviewed Sep 24, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. Python 3155 lines · 3.8K tokens
  2. DSPy 3.3.171 lines · 3K tokens
Total226 lines · 6.8K 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
  • 524
  • 532
  • 611
  • 674
  • 732
  • 770
  • 772
  • 776
  • 778
  • 807
  • 829
  • 862
  • 916
  • 918
  • 941
  • 1104
  • 1333
  • 1395
  • 1426
  • 1427

Prompt Preview

Apply the Python 3 baseline first. These rules cover the dspy 3.3.1 distribution on Python 3.10–3.14, including models, adapters, tools, ReAct, experimental ReActV2, RLM, optimization, and persistence.

Model configuration and input boundaries

  • Construct dspy.LM with server-selected providers, models, endpoints, headers, and credentials; give distinct tenants or workloads separate provider permissions and quotas where their trust differs.
  • Set process defaults with dspy.configure before serving requests and use dspy.context for trusted request-scoped overrides. Context overrides do not clone shared LM, callback, or trace objects; do not mutate those objects across tenants.
  • Map request data to an explicit allowlist of business inputs before calling Predict; keep its lm, signature, demos, config, prediction, and _trace overrides under application control instead of unpacking arbitrary request dictionaries.
  • Validate required inputs, types, lengths, and unknown fields before Predict. Its missing-input and type-mismatch warnings are not rejection, and warn_on_type_mismatch=True does not enforce a schema.
  • Set dspy.LM output limits with max_tokens, bound num_retries, and configure provider timeouts. Budget the complete module graph, parallel workers, adapter retries, and tool calls; track_usage=True reports usage but does not enforce a spending ceiling.

Predictions, retrieval, and media

  • Keep signatures and module definitions in trusted code. Treat demonstrations, retrieved passages, History, tool results, and model reasoning