diff --git a/apps/sim/blocks/blocks/google_drive.test.ts b/apps/sim/blocks/blocks/google_drive.test.ts index 000389f90ca..4d475a3e1d2 100644 --- a/apps/sim/blocks/blocks/google_drive.test.ts +++ b/apps/sim/blocks/blocks/google_drive.test.ts @@ -106,4 +106,17 @@ describe('GoogleDriveBlock agent tool calls', () => { it('drops a list page token left over on the canvas under search', () => { expect(buildParams({ operation: 'search', pageToken: 'stale' }).pageToken).toBeUndefined() }) + + it('drops a list page token left over on the canvas under a non-paginating operation', () => { + expect(buildParams({ operation: 'get_file', pageToken: 'stale' }).pageToken).toBeUndefined() + }) + + /** A stored agent tool keeps its operation on the tool, not in the args the mapper receives. */ + it.each(['list', 'search', 'list_permissions', 'list_revisions', 'list_comments'])( + 'keeps the model pageToken on %s when the args carry no operation', + (operation) => { + const args = { fileId: 'f-1', pageToken: 'next' } + expect({ ...args, ...buildParams(args, { operation }) }.pageToken).toBe('next') + } + ) }) diff --git a/apps/sim/blocks/blocks/google_drive.ts b/apps/sim/blocks/blocks/google_drive.ts index 0d10ba8aaf6..49d346bc529 100644 --- a/apps/sim/blocks/blocks/google_drive.ts +++ b/apps/sim/blocks/blocks/google_drive.ts @@ -1704,7 +1704,8 @@ Return ONLY the comment text - no explanations, no quotes, no extra formatting.` effectivePageToken = revisionsPageToken || agentPageToken else if (params.operation === 'list_comments') effectivePageToken = commentsPageToken || agentPageToken - else if (params.operation !== 'list') effectivePageToken = undefined + // The canvas list token is stale for every other operation; an agent's own token is not + else if (params.operation !== 'list') effectivePageToken = agentPageToken const effectiveQuery = params.operation === 'search'