Skip to content

[Discovery Engine] streamAnswer is typed as one AnswerQueryResponse, but REST returns frame arrays #3930

Description

@glaziermag

Description

@googleapis/discoveryengine exposes the REST servingConfigs.streamAnswer method as if the default parsed response is one Schema$GoogleCloudDiscoveryengineV1AnswerQueryResponse.

However, direct REST streamAnswer returns a JSON array of AnswerQueryResponse frames. With the default generated method, res.data is that array at runtime, while TypeScript and the generated example tell users to treat res.data as a single object. Typed code can therefore read res.data.answerQueryToken or res.data.answer?.relatedQuestions and get undefined, even though those fields are present in the returned frames.

This is not an answer-quality issue and does not require any live Google call to reproduce. The fixture below is a redacted HTTP 200 direct REST streamAnswer body from Discovery Engine / Vertex AI Search.

Package / source

The generated comment says the method is streaming and returns multiple AnswerQueryResponse messages, but the default overload returns Promise<GaxiosResponseWithHTTP2<Schema$GoogleCloudDiscoveryengineV1AnswerQueryResponse>>.

Reproduction

Create these files and run one command:

npm install && npm run repro

package.json:

{
  "type": "module",
  "scripts": {
    "repro": "node repro.mjs && tsc --noEmit --strict --target es2022 --lib es2022 --module nodenext --moduleResolution nodenext typecheck.ts"
  },
  "dependencies": {
    "@googleapis/discoveryengine": "30.0.0",
    "@types/node": "24.10.1",
    "nock": "14.0.10",
    "typescript": "5.9.3"
  }
}

repro.mjs:

import fs from 'node:fs';
import nock from 'nock';
import {discoveryengine} from '@googleapis/discoveryengine';

const fixture = JSON.parse(fs.readFileSync('./fixture.json', 'utf8'));
const servingConfig =
  'projects/testing-repos-489801/locations/global/collections/default_collection/dataStores/large-session-details-20260618-025044-m6sk/servingConfigs/default_search';

nock.disableNetConnect();
nock('https://discoveryengine.googleapis.com')
  .post(`/v1/${servingConfig}:streamAnswer`)
  .query(true)
  .reply(200, fixture, {'content-type': 'application/json'});

const api = discoveryengine('v1');
const res = await api.projects.locations.collections.dataStores.servingConfigs.streamAnswer({
  servingConfig,
  requestBody: {query: {text: 'offline replay'}},
});

const framesWithRelatedQuestions = res.data.filter(
  frame => frame.answer?.relatedQuestions?.length
);
const framesWithTokens = res.data.filter(frame => frame.answerQueryToken);

console.log(`Array.isArray(res.data): ${Array.isArray(res.data)}`);
console.log(`res.data.answerQueryToken: ${String(res.data.answerQueryToken)}`);
console.log(`res.data.answer?.relatedQuestions: ${String(res.data.answer?.relatedQuestions)}`);
console.log(`frame count: ${res.data.length}`);
console.log(`frames with answerQueryToken: ${framesWithTokens.length}`);
console.log(`frames with relatedQuestions: ${framesWithRelatedQuestions.length}`);
console.log(`first relatedQuestions count: ${framesWithRelatedQuestions[0]?.answer.relatedQuestions.length ?? 0}`);

typecheck.ts:

import {discoveryengine_v1} from '@googleapis/discoveryengine';

const api = new discoveryengine_v1.Discoveryengine({});
const servingConfig =
  'projects/testing-repos-489801/locations/global/collections/default_collection/dataStores/large-session-details-20260618-025044-m6sk/servingConfigs/default_search';

async function main() {
  const res =
    await api.projects.locations.collections.dataStores.servingConfigs.streamAnswer({
      servingConfig,
      requestBody: {query: {text: 'offline replay'}},
    });

  // These compile because streamAnswer is typed as a single AnswerQueryResponse.
  const token: string | null | undefined = res.data.answerQueryToken;
  const relatedQuestions: string[] | undefined =
    res.data.answer?.relatedQuestions ?? undefined;

  // This is the runtime shape for valid REST streamAnswer output, but the
  // generated default type rejects it.
  // @ts-expect-error streamAnswer is typed as unary, not array-of-frame.
  const frameCount: number = res.data.length;

  console.log(token, relatedQuestions, frameCount);
}

void main();
fixture.json (redacted HTTP 200 direct REST streamAnswer body)
[
  {
    "answer": {
      "state": "STREAMING",
      "steps": [
        {
          "state": "SUCCEEDED",
          "description": "Rephrase the query and search.",
          "actions": [
            {
              "searchAction": {
                "query": "For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, what are the alpha, beta, gamma, and delta review requirements? Include citations."
              },
              "observation": {
                "searchResults": [
                  {
                    "document": "projects/917493783080/locations/global/collections/default_collection/dataStores/large-session-details-20260618-025044-m6sk/branches/0/documents/large-session-include-details-doc",
                    "structData": {
                      "body": "Section 1: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 1; the support region is us-west; the effective date is 2026-06-11. Citations should point to this structured source and compare repeated facts across sections. Section 2: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 2; the support region is us-west; the effective date is 2026-06-12. Citations should point to this structured source and compare repeated facts across sections. Section 3: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 3; the support region is us-west; the effective date is 2026-06-13. Citations should point to this structured source and compare repeated facts across sections. Section 4: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 4; the support region is us-west; the effective date is 2026-06-14. Citations should point to this structured source and compare repeated facts across sections. Section 5: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 5; the support region is us-west; the effective date is 2026-06-15. Citations should point to this structured source and compare repeated facts across sections. Section 6: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 6; the support region is us-west; the effective date is 2026-06-16. Citations should point to this structured source and compare repeated facts across sections. Section 7: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 7; the support region is us-west; the effective date is 2026-06-17. Citations should point to this structured source and compare repeated facts across sections. Section 8: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 8; the support region is us-west; the effective date is 2026-06-18. Citations should point to this structured source and compare repeated facts across sections.",
                      "source_uri": "agent-search-test://large_session_include_details_20260618-025044_42p3u/large-session-include-details-doc",
                      "title": "Large session includeAnswerDetails parity sentinel",
                      "run_id": "large_session_include_details_20260618-025044_42p3u",
                      "unicode_notes": "Accents: cafe naive facade. Emoji: checkmark OK. Long dash: alpha -- beta. Greek: lambda pi. Japanese: テスト. Arabic: اختبار.",
                      "version": 1,
                      "sentinel_token": "large_session_include_details_large_session_include_details_20260618-025044_42p3u",
                      "facts": "The release code is R-ALPHA-77. The escalation owner is Search Credit QA. The support region is us-west. The policy labels are standard-search and advanced-generative-answer. Reviewers should verify manual review, automatic approval, escalation, and audit evidence."
                    }
                  }
                ]
              }
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "references": [
        {
          "structuredDocumentInfo": {
            "document": "projects/917493783080/locations/global/collections/default_collection/dataStores/large-session-details-20260618-025044-m6sk/branches/0/documents/large-session-include-details-doc",
            "structData": {},
            "title": "Large session includeAnswerDetails parity sentinel"
          }
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "For"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": " the sentinel `large_session_include_details_large_session_include_details_20"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "260618-025044_42p3"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "u`, the review requirements are as follows: alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "-stamped audit note. "
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "endIndex": "276",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "The support region for this sentinel is us-west. "
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "277",
          "endIndex": "325",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "The policy labels associated with this sentinel are standard-search and advanced-generative"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "-answer. "
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "326",
          "endIndex": "425",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "Reviewers should verify manual review, automatic approval, escalation, and audit evidence. "
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "426",
          "endIndex": "516",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "The release code is R-ALPHA-77. "
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "517",
          "endIndex": "548",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "The escalation owner is Search Credit QA.\n\n"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "549",
          "endIndex": "590",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "The section"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": " owner and effective date vary across different sections of the source:\n"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "*   Section 1: The section owner is Search Credit QA 1, and the effective date is 2026-06-11."
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "\n"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "675",
          "endIndex": "768",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "*   Section 2: The section owner is Search Credit QA 2, and the effective date is 2026-06-12.\n"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "769",
          "endIndex": "862",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "*   Section 3: The section owner is Search Credit QA 3, and the effective date is 2026-06"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "-13.\n"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "863",
          "endIndex": "956",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "*   Section 4: The section owner is Search Credit QA 4, and the effective date is 2026-06-14.\n"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "957",
          "endIndex": "1050",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "*   Section 5: The section owner is Search Credit QA 5, and the effective date is 2"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "026-06-15.\n"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "1051",
          "endIndex": "1144",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "*   Section 6: The section owner is Search Credit QA 6, and the effective date is 2026-06-16.\n"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "1145",
          "endIndex": "1238",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "*   Section 7: The section owner is Search Credit QA 7, and"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": " the effective date is 2026-06-17.\n"
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "1239",
          "endIndex": "1332",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "answerText": "*   Section 8: The section owner is Search Credit QA 8, and the effective date is 2026-06-18."
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "citations": [
        {
          "startIndex": "1333",
          "endIndex": "1426",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "STREAMING",
      "relatedQuestions": [
        "What is the escalation process for gamma?",
        "Who is the current section owner?",
        "What is the latest effective date?",
        "Where can I find this structured source?",
        "Can I get more details on \"manual review\"?"
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  },
  {
    "answer": {
      "state": "SUCCEEDED",
      "answerText": "For the sentinel `large_session_include_details_large_session_include_details_20260618-025044_42p3u`, the review requirements are as follows: alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The support region for this sentinel is us-west. The policy labels associated with this sentinel are standard-search and advanced-generative-answer. Reviewers should verify manual review, automatic approval, escalation, and audit evidence. The release code is R-ALPHA-77. The escalation owner is Search Credit QA.\n\nThe section owner and effective date vary across different sections of the source:\n*   Section 1: The section owner is Search Credit QA 1, and the effective date is 2026-06-11.\n*   Section 2: The section owner is Search Credit QA 2, and the effective date is 2026-06-12.\n*   Section 3: The section owner is Search Credit QA 3, and the effective date is 2026-06-13.\n*   Section 4: The section owner is Search Credit QA 4, and the effective date is 2026-06-14.\n*   Section 5: The section owner is Search Credit QA 5, and the effective date is 2026-06-15.\n*   Section 6: The section owner is Search Credit QA 6, and the effective date is 2026-06-16.\n*   Section 7: The section owner is Search Credit QA 7, and the effective date is 2026-06-17.\n*   Section 8: The section owner is Search Credit QA 8, and the effective date is 2026-06-18.",
      "citations": [
        {
          "endIndex": "276",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "277",
          "endIndex": "325",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "326",
          "endIndex": "425",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "426",
          "endIndex": "516",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "517",
          "endIndex": "548",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "549",
          "endIndex": "590",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "675",
          "endIndex": "768",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "769",
          "endIndex": "862",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "863",
          "endIndex": "956",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "957",
          "endIndex": "1050",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "1051",
          "endIndex": "1144",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "1145",
          "endIndex": "1238",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "1239",
          "endIndex": "1332",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        },
        {
          "startIndex": "1333",
          "endIndex": "1426",
          "sources": [
            {
              "referenceId": "0"
            }
          ]
        }
      ],
      "references": [
        {
          "structuredDocumentInfo": {
            "document": "projects/917493783080/locations/global/collections/default_collection/dataStores/large-session-details-20260618-025044-m6sk/branches/0/documents/large-session-include-details-doc",
            "structData": {},
            "title": "Large session includeAnswerDetails parity sentinel"
          }
        }
      ],
      "relatedQuestions": [
        "What is the escalation process for gamma?",
        "Who is the current section owner?",
        "What is the latest effective date?",
        "Where can I find this structured source?",
        "Can I get more details on \"manual review\"?"
      ],
      "steps": [
        {
          "state": "SUCCEEDED",
          "description": "Rephrase the query and search.",
          "actions": [
            {
              "searchAction": {
                "query": "For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, what are the alpha, beta, gamma, and delta review requirements? Include citations."
              },
              "observation": {
                "searchResults": [
                  {
                    "document": "projects/917493783080/locations/global/collections/default_collection/dataStores/large-session-details-20260618-025044-m6sk/branches/0/documents/large-session-include-details-doc",
                    "structData": {
                      "unicode_notes": "Accents: cafe naive facade. Emoji: checkmark OK. Long dash: alpha -- beta. Greek: lambda pi. Japanese: テスト. Arabic: اختبار.",
                      "run_id": "large_session_include_details_20260618-025044_42p3u",
                      "title": "Large session includeAnswerDetails parity sentinel",
                      "body": "Section 1: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 1; the support region is us-west; the effective date is 2026-06-11. Citations should point to this structured source and compare repeated facts across sections. Section 2: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 2; the support region is us-west; the effective date is 2026-06-12. Citations should point to this structured source and compare repeated facts across sections. Section 3: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 3; the support region is us-west; the effective date is 2026-06-13. Citations should point to this structured source and compare repeated facts across sections. Section 4: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 4; the support region is us-west; the effective date is 2026-06-14. Citations should point to this structured source and compare repeated facts across sections. Section 5: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 5; the support region is us-west; the effective date is 2026-06-15. Citations should point to this structured source and compare repeated facts across sections. Section 6: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 6; the support region is us-west; the effective date is 2026-06-16. Citations should point to this structured source and compare repeated facts across sections. Section 7: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 7; the support region is us-west; the effective date is 2026-06-17. Citations should point to this structured source and compare repeated facts across sections. Section 8: For sentinel large_session_include_details_large_session_include_details_20260618-025044_42p3u, alpha requires manual review, beta is automatically approved, gamma requires escalation, and delta requires a date-stamped audit note. The section owner is Search Credit QA 8; the support region is us-west; the effective date is 2026-06-18. Citations should point to this structured source and compare repeated facts across sections.",
                      "source_uri": "agent-search-test://large_session_include_details_20260618-025044_42p3u/large-session-include-details-doc",
                      "facts": "The release code is R-ALPHA-77. The escalation owner is Search Credit QA. The support region is us-west. The policy labels are standard-search and advanced-generative-answer. Reviewers should verify manual review, automatic approval, escalation, and audit evidence.",
                      "sentinel_token": "large_session_include_details_large_session_include_details_20260618-025044_42p3u",
                      "version": 1
                    }
                  }
                ]
              }
            }
          ]
        }
      ]
    },
    "answerQueryToken": "NMwKDAiomezRBhDUgaihAhIkNmEzZGU2MjMtMDAwMC0yNTIwLTg0YzctMDg5ZTA4MmNlZmNj"
  }
]

Actual output

Array.isArray(res.data): true
res.data.answerQueryToken: undefined
res.data.answer?.relatedQuestions: undefined
frame count: 43
frames with answerQueryToken: 43
frames with relatedQuestions: 2
first relatedQuestions count: 5

Expected behavior

The generated REST surface should not expose the default parsed streamAnswer response as a single AnswerQueryResponse when valid REST output is an array of AnswerQueryResponse frames.

Possible fixes could be one of:

  • Type the default parsed response as Schema$GoogleCloudDiscoveryengineV1AnswerQueryResponse[].
  • Document and type streamAnswer so callers must use responseType: 'stream' for this endpoint.
  • Provide a higher-level accumulator that returns a final assembled Answer response and preserves terminal frame metadata such as answerQueryToken and relatedQuestions.

Why the fixture is valid

The body is from a direct REST streamAnswer HTTP 200 response from discoveryengine.googleapis.com. The service returned a JSON array of AnswerQueryResponse frames. The raw service output is the ground truth here; the issue is only that the public Node REST client type/default wrapper presents that valid output as a unary object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions