Mixing `file_search` results in type validation error; `file_citation` annotations lack `start_index`, `end_index`, `quote`

### Description

follow up to https://github.com/vercel/ai/issues/8030#issuecomment-3191527471

When using `generateText` with both `web_search_preview` and `file_search` tools in AI SDK v5, the call fails with an `AI_TypeValidationError` sometimes.

This happens when the OpenAI Responses API does not return `start_index`, `end_index`, and `quote` fields.

The OpenAI Responses API returns valid `file_citation` objects with `file_id`, `filename`, and `index`, but the AI SDK validator expects them to also have the `start_index`, `end_index`, and `quote` properties (like `url_citation` annotations). This leads to `AI_TypeValidationError` failures during parsing.

**Reproduction**

```ts
import { generateText, openai } from 'ai';

const result = await generateText({
  model: openai('gpt-5'),
  system: 'system prompt here',
  prompt: 'prompt here',
  tools: {
    web_search_preview: openai.tools.webSearchPreview({ searchContextSize: 'high' }),
    file_search: openai.tools.fileSearch({
      vectorStoreIds: ['myvectorstoreid'],
      maxNumResults: 3,
    }),
  },
});
```

### Observed Behavior
```
AI_APICallError: Invalid JSON response
AI_TypeValidationError: Invalid input: expected number, received undefined
Path: ["output", 11, "content", 0, "annotations", 0, "start_index"]
```
This repeats for start_index, end_index, and quote on each file_citation annotation.

### Example of Returned `file_citation` Objects
```json
{
  "type": "file_citation",
  "file_id": "file-XXXX",
  "filename": "ev-database-BEV-m1.json",
  "index": 145
}
```

### Full error paste

```json
error: {
      "name": "AI_APICallError",
      "cause": {
        "name": "AI_TypeValidationError",
        "cause": [
          {
            "expected": "number",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              0,
              "start_index"
            ],
            "message": "Invalid input: expected number, received undefined"
          },
          {
            "expected": "number",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              0,
              "end_index"
            ],
            "message": "Invalid input: expected number, received undefined"
          },
          {
            "expected": "string",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              0,
              "quote"
            ],
            "message": "Invalid input: expected string, received undefined"
          },
          {
            "expected": "number",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              1,
              "start_index"
            ],
            "message": "Invalid input: expected number, received undefined"
          },
          {
            "expected": "number",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              1,
              "end_index"
            ],
            "message": "Invalid input: expected number, received undefined"
          },
          {
            "expected": "string",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              1,
              "quote"
            ],
            "message": "Invalid input: expected string, received undefined"
          },
          {
            "expected": "number",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              2,
              "start_index"
            ],
            "message": "Invalid input: expected number, received undefined"
          },
          {
            "expected": "number",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              2,
              "end_index"
            ],
            "message": "Invalid input: expected number, received undefined"
          },
          {
            "expected": "string",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              2,
              "quote"
            ],
            "message": "Invalid input: expected string, received undefined"
          },
          {
            "expected": "number",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              3,
              "start_index"
            ],
            "message": "Invalid input: expected number, received undefined"
          },
          {
            "expected": "number",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              3,
              "end_index"
            ],
            "message": "Invalid input: expected number, received undefined"
          },
          {
            "expected": "string",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              3,
              "quote"
            ],
            "message": "Invalid input: expected string, received undefined"
          },
          {
            "expected": "number",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              4,
              "start_index"
            ],
            "message": "Invalid input: expected number, received undefined"
          },
          {
            "expected": "number",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              4,
              "end_index"
            ],
            "message": "Invalid input: expected number, received undefined"
          },
          {
            "expected": "string",
            "code": "invalid_type",
            "path": [
              "output",
              11,
              "content",
              0,
              "annotations",
              4,
              "quote"
            ],
            "message": "Invalid input: expected string, received undefined"
          }
        ],
        "value": {
          "id": "resp_68221f34048",
          "object": "response",
          "created_at": 1775343728,
          "status": "completed",
          "background": false,
          "error": null,
          "incomplete_details": null,
          "instructions": null,
          "max_output_tokens": null,
          "max_tool_calls": null,
          "model": "gpt-5-2025-08-07",
          "output": [
            {
              "id": "rs_689f32f0ec00819997e09cd459ced1b",
              "type": "reasoning",
              "summary": []
            },
            {
              "id": "fs_689f32fe1a508199ae29a88e34c05d1b",
              "type": "file_search_call",
              "status": "completed",
              "queries": [
                "2017",
                "2018",
                "2019",
                "2020",
              ],
              "results": null
            },
            {
              "id": "rs_689f3300fd108199a914bfe2d59fb5d1b",
              "type": "reasoning",
              "summary": []
            },
            {
              "id": "fs_689f3309e89c8199b0e036c79b5d1b",
              "type": "file_search_call",
              "status": "completed",
              "queries": [
                "2019",
                "2018 file",
                "2017"
              ],
              "results": null
            },
            {
              "id": "rs_689f330c3ad4819987363508de709270d1b",
              "type": "reasoning",
              "summary": []
            },
            {
              "id": "fs_689f330ed9ec8199a55ab42adcb0b5d1b",
              "type": "file_search_call",
              "status": "completed",
              "queries": [
                "2019",
                "2018",
                "2017"
              ],
              "results": null
            },
            {
              "id": "rs_689f33112e388199a37b1aafdbfb5d1b",
              "type": "reasoning",
              "summary": []
            },
            {
              "id": "fs_689f3315c40881998f420e51fa5d1b",
              "type": "file_search_call",
              "status": "completed",
              "queries": [
                "2019",
                "2018",
                "2017 file"
              ],
              "results": null
            },
            {
              "id": "rs_689f3318296c81998fac36759fb5d1b",
              "type": "reasoning",
              "summary": []
            },
            {
              "id": "fs_689f3325e410819991d1cc29fb5d1b",
              "type": "file_search_call",
              "status": "completed",
              "queries": [
                "2019",
                "2018",
                "2017"
              ],
              "results": null
            },
            {
              "id": "rs_689f3318227c8199943d8d390f811b",
              "type": "reasoning",
              "summary": []
            },
            {
              "id": "msg_689f332d417c819994d4ef0bcb",
              "type": "message",
              "status": "completed",
              "content": [
                {
                  "type": "output_text",
                  "annotations": [
                    {
                      "type": "file_citation",
                      "file_id": "file-YRcoCqn3Fo2K4JgraG",
                      "filename": "resource1.json",
                      "index": 145
                    },
                    {
                      "type": "file_citation",
                      "file_id": "file-YRcoCqn3Fo2K4JgraG",
                      "filename": "resource1.json",
                      "index": 192
                    },
                    {
                      "type": "file_citation",
                      "file_id": "file-YRcoCqn3Fo2K4JgraG",
                      "filename": "resource1.json",
                      "index": 437
                    },
                    {
                      "type": "file_citation",
                      "file_id": "file-YRcoCqn3Fo2K4JgraG",
                      "filename": "resource1.json",
                      "index": 602
                    },
                    {
                      "type": "file_citation",
                      "file_id": "file-YRcoCqn3Fo2K4JgraG",
                      "filename": "resource1.json",
                      "index": 913
                    }
                  ],
                  "logprobs": [],
                  "text": "Answer for the specified years ...."
                }
              ],
              "role": "assistant"
            }
          ],
          "parallel_tool_calls": true,
          "previous_response_id": null,
          "prompt_cache_key": null,
          "reasoning": {
            "effort": "high",
            "summary": null
          },
          "safety_identifier": null,
          "service_tier": "flex",
          "store": true,
          "temperature": 1,
          "text": {
            "format": {
              "type": "text"
            },
            "verbosity": "medium"
          },
          "tool_choice": "auto",
          "tools": [
            {
              "type": "file_search",
              "filters": null,
              "max_num_results": 4,
              "ranking_options": {
                "ranker": "auto",
                "score_threshold": 0
              },
              "vector_store_ids": [
                "vs_689ccdfa981918d2b1f3b3de"
              ]
            },
            {
              "type": "web_search_preview",
              "search_context_size": "high",
              "user_location": {
                "type": "approximate",
                "city": null,
                "country": "US",
                "region": null,
                "timezone": null
              }
            }
          ],
          "top_logprobs": 0,
          "top_p": 1,
          "truncation": "disabled",
          "usage": {
            "input_tokens": 109777,
            "input_tokens_details": {
              "cached_tokens": 82688
            },
            "output_tokens": 6090,
            "output_tokens_details": {
              "reasoning_tokens": 5760
            },
            "total_tokens": 115867
          },
          "user": null,
          "metadata": {}
        },
        "stack":
            AI_TypeValidationError: Type validation failed: Value: {"id":"resp_68221f34048","object":"response","created_at":1775343728,"status":"completed","background":false,"error":null,"incomplete_details":null,"instructions":null,"max_output_tokens":null,"max_tool_calls":null,"model":"gpt-5-2025-08-07","output":[{"id":"rs_689f32f0ec00819997e09cd459ced1b","type":"reasoning","summary":[]},{"id":"fs_689f32fe1a508199ae29a88e34c05d1b","type":"file_search_call","status":"completed","queries":["2017","2019","2017"],"results":null},{"id":"rs_689f3300fd108199a914bfe2d59fb5d1b","type":"reasoning","summary":[]},{"id":"fs_689f3309e89c8199b0e036c79b5d1b","type":"file_search_call","status":"completed","queries":["2019","2018 file","2017"],"results":null},{"id":"rs_689f330c3ad4819987363508de709270d1b","type":"reasoning","summary":[]},{"id":"fs_689f330ed9ec8199a55ab42adcb0b5d1b","type":"file_search_call","status":"completed","queries":["2018","2019 file","2016"],"results":null},{"id":"rs_689f33112e388199a37b1aafdbfb5d1b","type":"reasoning","summary":[]},{"id":"fs_689f3315c40881998f420e51fa5d1b","type":"file_search_call","status":"completed","queries":["2019","2017","2018 file","2020"],"results":null},{"id":"rs_689f3318296c81998fa2b756af60149fb5d1b","type":"reasoning","summary":[]},{"id":"fs_689f3325e410819991d1cc29fb5d1b","type":"file_search_call","status":"completed","queries":["2019","2018","2017"],"results":null},{"id":"rs_689f3318227c8199943d8d390f811b","type":"reasoning","summary":[]},{"id":"msg_689f332d417c819994d4ef0bcb","type":"message","status":"completed","content":[{"type":"output_text","annotations":[{"type":"file_citation","file_id":"file-YRcoCqn3Fo2K4JgraG","filename":"resource1.json","index":145},{"type":"file_citation","file_id":"file-YRcoCqn3Fo2K4JgraG","filename":"resource1.json","index":192},{"type":"file_citation","file_id":"file-YRcoCqn3Fo2K4JgraG","filename":"resource1.json","index":437},{"type":"file_citation","file_id":"file-YRcoCqn3Fo2K4JgraG","filename":"resource1.json","index":602},{"type":"file_citation","file_id":"file-YRcoCqn3Fo2K4JgraG","filename":"resource1.json","index":913}],"logprobs":[],"text":"Answer for the specified years ...."}],"role":"assistant"}],"parallel_tool_calls":true,"previous_response_id":null,"prompt_cache_key":null,"reasoning":{"effort":"high","summary":null},"safety_identifier":null,"service_tier":"flex","store":true,"temperature":1,"text":{"format":{"type":"text"},"verbosity":"medium"},"tool_choice":"auto","tools":[{"type":"file_search","filters":null,"max_num_results":4,"ranking_options":{"ranker":"auto","score_threshold":0},"vector_store_ids":["vs_689ccdfa981918d2b1f3b3de"]},{"type":"web_search_preview","search_context_size":"high","user_location":{"type":"approximate","city":null,"country":"US","region":null,"timezone":null}}],"top_logprobs":0,"top_p":1,"truncation":"disabled","usage":{"input_tokens":109777,"input_tokens_details":{"cached_tokens":82688},"output_tokens":6090,"output_tokens_details":{"reasoning_tokens":5760},"total_tokens":115867},"user":null,"metadata":{}}.
            Error message: [{"expected":"number","code":"invalid_type","path":["output",11,"content",0,"annotations",0,"start_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"number","code":"invalid_type","path":["output",11,"content",0,"annotations",0,"end_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"string","code":"invalid_type","path":["output",11,"content",0,"annotations",0,"quote"],"message":"Invalid input: expected string, received undefined"},{"expected":"number","code":"invalid_type","path":["output",11,"content",0,"annotations",1,"start_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"number","code":"invalid_type","path":["output",11,"content",0,"annotations",1,"end_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"string","code":"invalid_type","path":["output",11,"content",0,"annotations",1,"quote"],"message":"Invalid input: expected string, received undefined"},{"expected":"number","code":"invalid_type","path":["output",11,"content",0,"annotations",2,"start_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"number","code":"invalid_type","path":["output",11,"content",0,"annotations",2,"end_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"string","code":"invalid_type","path":["output",11,"content",0,"annotations",2,"quote"],"message":"Invalid input: expected string, received undefined"},{"expected":"number","code":"invalid_type","path":["output",11,"content",0,"annotations",3,"start_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"number","code":"invalid_type","path":["output",11,"content",0,"annotations",3,"end_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"string","code":"invalid_type","path":["output",11,"content",0,"annotations",3,"quote"],"message":"Invalid input: expected string, received undefined"},{"expected":"number","code":"invalid_type","path":["output",11,"content",0,"annotations",4,"start_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"number","code":"invalid_type","path":["output",11,"content",0,"annotations",4,"end_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"string","code":"invalid_type","path":["output",11,"content",0,"annotations",4,"quote"],"message":"Invalid input: expected string, received undefined"}]
                at Object.validate (file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:403:14)
                at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
                at async safeValidateTypes (file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:431:20)
                at async safeParseJSON (file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:476:12)
                at async file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:820:24
                at async postToApi (file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:625:14)
                at async OpenAIResponsesLanguageModel.doGenerate (file:///repo/node_modules/@ai-sdk/openai/dist/index.mjs:2358:9)
                at async fn (file:///repo/node_modules/ai/dist/index.mjs:2169:34)
                at async file:///repo/node_modules/ai/dist/index.mjs:1451:22
                at async _retryWithExponentialBackoff (file:///repo/node_modules/ai/dist/index.mjs:1602:12)
      },
```





### AI SDK Version

- "ai": "^5.0.14"
- "@ai-sdk/openai": "^2.0.14"

Labels: bug, ai/provider, provider/openai
State: closed