DSPy 3.3.1
Last reviewed Sep 24, 2026
Prompt Details
Prompt Composition
2prompts
- Python 3155 lines · 3.8K tokens
- 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.LMwith 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.configurebefore serving requests and usedspy.contextfor 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 itslm,signature,demos,config,prediction, and_traceoverrides 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, andwarn_on_type_mismatch=Truedoes not enforce a schema. - Set
dspy.LMoutput limits withmax_tokens, boundnum_retries, and configure provider timeouts. Budget the complete module graph, parallel workers, adapter retries, and tool calls;track_usage=Truereports 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