Skip to content

[Firebase AI] URL Context tool intermittently throws 500 errors on Google AI #15385

@andrewheard

Description

@andrewheard

Description

Using the URL Context tool with the Gemini Developer API (Google AI) frequently results in HTTP 500 errors from the backend.

Reproducing the issue

The integration test intermittently fails:

@Test(
"generateContent with URL Context",
arguments: InstanceConfig.allConfigs
)
func generateContent_withURLContext_succeeds(_ config: InstanceConfig) async throws {
let model = FirebaseAI.componentInstance(config).generativeModel(
modelName: ModelNames.gemini2_5_Flash,
tools: [.urlContext()]
)
let prompt = """
Write a one paragraph summary of this blog post: \
https://developers.googleblog.com/en/introducing-gemma-3-270m/
"""
let response = try await model.generateContent(prompt)
let candidate = try #require(response.candidates.first)
let urlContextMetadata = try #require(candidate.urlContextMetadata)
#expect(urlContextMetadata.urlMetadata.count == 1)
let urlMetadata = try #require(urlContextMetadata.urlMetadata.first)
let retrievedURL = try #require(urlMetadata.retrievedURL)
#expect(
retrievedURL == URL(string: "https://developers.googleblog.com/en/introducing-gemma-3-270m/")
)
#expect(urlMetadata.retrievalStatus == .success)
}

Firebase SDK Version

12.4.0

Xcode Version

26.0

Installation Method

Swift Package Manager

Firebase Product(s)

AI Logic

Targeted Platforms

All

Relevant Log Output

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions