Pydantic AI 2
Last reviewed Oct 25, 2026
Prompt Details
Prompt Composition
3prompts
- Python 3155 lines · 3.8K tokens
- Pydantic 2.1459 lines · 2.7K tokens
- Pydantic AI 261 lines · 3.1K tokens
Total275 lines · 9.7K tokens
CWE Coverage
- 20
- 23
- 36
- 59
- 73
- 78
- 89
- 93
- 95
- 117
- 201
- 208
- 209
- 214
- 250
- 295
- 306
- 319
- 328
- 338
- 346
- 347
- 352
- 367
- 379
- 407
- 409
- 416
- 426
- 427
- 459
- 470
- 488
- 502
- 522
- 532
- 611
- 639
- 674
- 732
- 770
- 772
- 776
- 807
- 829
- 862
- 915
- 916
- 918
- 942
- 1104
- 1284
- 1287
- 1333
- 1395
- 1426
- 1427
Prompt Preview
Apply these rules to Pydantic AI V2 agents, tools, UI adapters, and integrations, with the included Pydantic and Python baselines. Check the installed minor's API before using newer V2 capabilities; keep the same authorization and resource boundaries when implementing an equivalent control.
Prompt injection and conversation state
- Keep
Agent(instructions=...),system_prompt, dynamic instruction callbacks, andSystemPromptPartunder application control. Pass user text, retrieved documents, memory, tool responses, and background results as data, never concatenate them into trusted instructions. Prompt framing and guardrail models do not grant authority. - Treat
message_historyas security-sensitive state. Store authoritative histories and pending operations server-side, partitioned by authenticated user and tenant; authorize conversation IDs before loading or resuming them.ModelMessagesTypeAdaptervalidates structure, not provenance. - When accepting client history, use
sanitize_messagesand retain the UI adapters' defaultmanage_system_prompt='server'and stripping of privileged parts. Do not setallow_uploaded_files=True, widenallowed_file_url_schemesorallowed_file_url_force_download, or setstrip_workspace_refs=Falsewithout independently authorizing each referenced resource. Sanitization does not authenticate tool calls, results, or approvals. - Apply the same trust separation to compaction, memory, and history-processing capabilities. Do not turn a summary of untrusted text into new policy or preserve client-supplied approval state as