Repository: promptfoo/promptfoo
Issue: Gemini: Support merging config and assertion systemInstructions using parts
Root cause: Validation Gap

**Describe the bug**

The Gemini provider throws a "Template error: system instruction defined in prompt and config" error when both `config.systemInstruction` and assertion-added system messages are present. This prevents users from setting a global system instruction in the provider config while using model-graded assertions.

Several assertions provide system messages for grading, including:
- `llm-rubric` - for custom rubric-based evaluation
- `model-graded-factuality` - for factuality checking
- Other model-graded assertion types

These assertions cannot be used in combination with `config.systemInstruction` due to this conflict.

A common use case is setting a global instruction like "Think in English and output the evaluation results in Japanese" in `config.systemInstruction`, which should apply to all model-graded assertions. This allows consistent output language and thinking process across all evaluations.


**To Reproduce**

## Reproduction

The issue occurs when:
1. Provider config includes `systemInstruction`
2. A test uses a model-graded assertion (e.g., `llm-rubric`) which internally provides a system message for grading
3. Both system instructions conflict and throw an error

**Reproduction configuration** (`promptfooconfig.yaml`):

```yaml
prompts:
- What is 2+2?

providers:
- vertex:gemini-2.5-flash

defaultTest:
  options:
    provider:
      id: vertex:gemini-2.5-flash
      config:
        systemInstruction: |
          You are a pirate.
          You MUST respond to EVERY question using pirate language with 'Arrr', 'matey', 'ye', etc.
          Never use normal English.

tests:
- assert:
  - type: llm-rubric
    value: |
      Evaluate the output
      Score of 0.0: Response does not answer the math question
      Score of 0.5: Response answers the math question
      Score of 1.0: Response answers the math question correctly (the answer is 4)
    threshold: 1.0
```

Running `promptfoo eval` with this configuration will produce the error.


**Expected behavior**

Currently, the `geminiFormatAndSystemInstructions` function in `src/providers/google/util.ts` throws an error when both system instructions are present. However, this conflict can be avoided by leveraging the Gemini API's native support for multiple `parts` within a single `systemInstruction`.

The Gemini API allows only one `systemInstruction` per request, but this instruction can contain multiple `parts`. The Gemini provider should merge both system instructions (from config and from model-graded assertions) into a single `systemInstruction` with multiple parts:

```json
{
  "systemInstruction": {
    "parts": [
      {"text": "config system instruction"},
      {"text": "model-graded assertion system message"}
    ]
  }
}
```

By separating them as distinct parts, both the user's config-level system instruction and the model-graded assertion's system message can be included without conflict.

Merge order should be: config parts first, then assertion parts. This allows the config to set general instructions while assertions add specific grading instructions.


**Screenshots**

<img width="878" height="441" alt="Image" src="https://github.com/user-attachments/assets/9facc54d-a0bf-4d80-8ea8-21669f7ce44a" />

**System information:**

If possible, please output the results of `promptfoo debug` and paste the output here.

- Promptfoo version: 0.118.11

**Additional context**

I'll create a pull request to fix this issue

Other Related Issue

- #3656