Google Gen AI SDK for Python 2.33

Last reviewed Oct 24, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. Python 3155 lines · 3.8K tokens
  2. Google Gen AI SDK for Python 2.3353 lines · 3K tokens
Total208 lines · 6.8K tokens

CWE Coverage

  • 20
  • 23
  • 36
  • 59
  • 73
  • 78
  • 79
  • 89
  • 95
  • 117
  • 201
  • 208
  • 209
  • 214
  • 250
  • 294
  • 295
  • 306
  • 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
  • 862
  • 916
  • 918
  • 941
  • 1104
  • 1333
  • 1395
  • 1426
  • 1427

Prompt Preview

Apply to Google Gen AI SDK for Python 2.33 with the included Python 3 baseline. Select the Gemini Developer API or Gemini Enterprise Agent Platform (formerly Vertex AI) deliberately; their features and data policies differ.

Prompt injection and tool authorization

  • Keep GenerateContentConfig.system_instruction, tool declarations, model selection, and safety settings under application control. Treat user messages, uploaded documents, retrieved text, cached content, and tool responses as untrusted data; none may grant authority or replace trusted instructions.
  • Construct types.Content roles on the server. Do not accept arbitrary client-supplied conversation roles, function-call parts, or function-response parts as authentic history; SDK conversion can turn function-call parts into model content.
  • Passing Python callables in tools enables automatic function calling. For privileged operations, set automatic_function_calling=types.AutomaticFunctionCallingConfig(disable=True) and dispatch returned response.function_calls only through a fixed registry after checking the current principal, operation, validated arguments, and target resource. If using automatic calls, put the same checks inside each callable before side effects.
  • Validate tool arguments against application constraints and reject unknown functions and fields. A FunctionDeclaration, function-calling mode, or schema-conforming response is not tool authorization. Bind any approval to the exact operation and arguments, and recheck permissions when executing.
  • Apply the same authorization to