diff --git a/src/server/providers/fixtures/gemini-deep-research.md.txt b/src/server/providers/fixtures/gemini-deep-research.md.txt index db88d68e..bb436e11 100644 --- a/src/server/providers/fixtures/gemini-deep-research.md.txt +++ b/src/server/providers/fixtures/gemini-deep-research.md.txt @@ -23,6 +23,16 @@ specify tools to restrict or extend the agent's capabilities. | MCP Server | `mcp_server` | Connect to remote MCP servers for external tool access. | | File Search | `file_search` | Search your uploaded document corpora. | -### Google Search {% id="google-search" %} +### MCP servers {% id="mcp-servers" %} + +The Field column is the request field. Type is its JSON type, not a tool. + +| Field | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| `type` | `string` | Yes | Must be `"mcp_server"`. | +| `name` | `string` | No | A display name for the MCP server. | +| `headers` | `object` | No | Key-value pairs sent as HTTP headers. | +| `allowed_tools` | `array` | No | Restrict which tools from the server the agent may call. | + ## Steerability and formatting {% id="steerability-and-formatting" %} diff --git a/src/server/providers/gemini-features.ts b/src/server/providers/gemini-features.ts index 396877c6..32d061dd 100644 --- a/src/server/providers/gemini-features.ts +++ b/src/server/providers/gemini-features.ts @@ -112,17 +112,31 @@ const GUIDE_TOOL_FIELDS: ReadonlySet = new Set([ ]) /** - * A guide's `## Supported tools` table: each backticked Type value is the + * The first pipe table in `text`. A later table in the same section is a + * different statement (Deep Research types the MCP `type` field as JSON + * `string` under `### MCP servers`, #773). + */ +function firstMarkdownTable(text: string): Array> { + const lines: Array = [] + for (const line of text.split('\n')) { + if (line.startsWith('|')) lines.push(line) + else if (lines.length > 0) break + } + return markdownTableRows(lines.join('\n')) +} + +/** + * A guide's `## Supported tools` catalog: each backticked Type value is the * Interactions API name of a generateContent `Tool` field - * (`google_search` → `googleSearch`). A guide with no such section states - * nothing; a section that yields no Type value, or a Type value outside the - * known fields, throws (#707). + * (`google_search` → `googleSearch`). Only that first table is the catalog. + * A guide with no such section states nothing; a catalog that yields no + * Type value, or a Type value outside the known fields, throws (#707). */ export function parseGuideTools(markdown: string): Array { const start = markdown.search(/^## Supported tools\b/m) if (start < 0) return [] const section = markdown.slice(start).split(/^## /m)[1] ?? '' - const [header, ...rows] = markdownTableRows(section) + const [header, ...rows] = firstMarkdownTable(section) const column = header?.findIndex((cell) => /^type value$/i.test(cell)) ?? -1 if (column < 0) throw new Error('gemini guide: Supported tools has no Type value column') diff --git a/src/server/providers/model-facts.ts b/src/server/providers/model-facts.ts index daaf5c71..191ddf06 100644 --- a/src/server/providers/model-facts.ts +++ b/src/server/providers/model-facts.ts @@ -299,7 +299,12 @@ export const DOCS_TTL_SECONDS = 6 * 60 * 60 // v49: a Gemini model page entry gained `guide`, the guide its // Documentation section links (#707). A v48 entry has none, so agent rows // would read no guide tools for six hours. -const DOCS_CACHE_VERSION = 'v49' +// v50: a Gemini guide caches the Supported tools catalog only (#773). A v49 +// entry was parsed from every table under the heading. Deep Research never +// stored one after the MCP field table arrived (its JSON `string` threw, and +// a failed load is not cached). The bump drops a v49 catalog stored before +// that table. +const DOCS_CACHE_VERSION = 'v50' /** Fresh-window key for one parsed docs page. Shared with the stale copy. */ export function docsCacheKey(url: string): string { diff --git a/src/server/providers/model-features.test.ts b/src/server/providers/model-features.test.ts index a3c137e5..fc576887 100644 --- a/src/server/providers/model-features.test.ts +++ b/src/server/providers/model-features.test.ts @@ -578,9 +578,10 @@ describe('gemini features (issue #77)', () => { it('reads a guide Supported tools table as generateContent fields (#707)', () => { // https://aistudio.google.com/docs/antigravity-agent.md and - // deep-research.md, 2026-11-21, cut down. `function` is a client - // tool; `mcp_server` becomes `mcpServer` by the same rule; Filesystem - // has no type value. + // deep-research.md, catalog from 2026-11-21, MCP field table from + // 2026-11-27, both cut down. `function` is a client tool; + // `mcp_server` becomes `mcpServer` by the same rule; Filesystem has + // no type value. The field table's JSON `string` is not a tool type. expect( parseGuideTools(fixture('gemini-antigravity-agent.md.txt')), ).toEqual(['codeExecution', 'googleSearch', 'urlContext', 'mcpServer']) @@ -601,6 +602,11 @@ describe('gemini features (issue #77)', () => { expect(() => parseGuideTools(guide.replace('`file_search`', '`file_lookup`')), ).toThrow(/file_lookup/) + // A catalog cell of `string` is an unknown tool type. The same word + // in the MCP field table, already in the fixture, is not. + expect(() => + parseGuideTools(guide.replace('`file_search`', '`string`')), + ).toThrow(/unknown Supported tools type "string"/) // A table that is there but yields no Type value is a changed format. expect(() => parseGuideTools(guide.replace(/`([a-z_]+)` \|/g, '$1 |')),