Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[bot] Google GenAI `generateImages` spans missing prompt input and use wrong span type

Open
#121 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
java
Domain
observability

Research direction

Start in braintrust-sdk/instrumentation/genai_1_18_0/src/main/java/com/google/genai/BraintrustApiClient.java, especially tagSpan lines 97–161, and review BraintrustGenAITest.java for existing span assertions. Add coverage for generateImages request and response parsing, including the prompt, image-generation metadata, and appropriate span categorization; done means the test verifies these values are captured instead of the current generateContent-only behavior.

Written by the indexing model from the issue text.

Description

Summary

When client.models.generateImages() is called through the instrumented Google GenAI client, a span is created (the call goes through ApiClient.request()), but the span contains no useful input data. The tagSpan() method in BraintrustApiClient only extracts fields specific to generateContent (contents, generationConfig, usageMetadata), which are absent from image generation requests and responses.

The result:

  • input_json only has {model: "..."} — the actual prompt text is not captured. This is the primary creative input and the most important thing to trace for image generation.
  • No metrics — image generation responses use response-level metadata (not usageMetadata), so no token or character counts are captured.
  • Wrong span type — hardcoded type: "llm" instead of something appropriate for image generation.

This is analogous to the embedContent gap tracked in #65, where calls are intercepted at HTTP level but parsed with the wrong field schema.

Braintrust already documents and traces generate_images for the Python SDK. The Java SDK makes the same API calls but the span tagging logic was never extended to handle them.

What is missing

BraintrustApiClient.tagSpan() (lines 50–161) handles only generateContent fields:

Request parsing (lines 97–113):

if (requestJson.containsKey("contents")) {          // generateContent field — not present in generateImages
    inputJson.put("contents", requestJson.get("contents"));
}
if (requestJson.containsKey("generationConfig")) {   // generateContent field — not present in generateImages
    inputJson.put("config", requestJson.get("generationConfig"));
}

A generateImages request body looks like:

{
  "prompt": "A photorealistic cat sitting on a moon",
  "config": {
    "numberOfImages": 2,
    "aspectRatio": "16:9",
    "negativePrompt": "blurry, low quality"
  }
}

Neither prompt nor config.numberOfImages/config.aspectRatio are extracted. The input_json stored in the span ends up as {model: "imagen-3.0-generate-001"} only — the prompt is silently dropped.

Response parsing (lines 116–149):

if (responseJson.get("usageMetadata") instanceof Map) {   // not present in generateImages responses
    ...
}

generateImages responses return generatedImages[].image.imageBytes (base64) and generatedImages[].generationParameters. No usageMetadata is present, so the metrics block is empty.

Span attributes (line 156):

span.setAttribute("braintrust.span_attributes", toJson(Map.of("type", "llm")));

Image generation is not an LLM call. Braintrust's Python tracer uses a different span categorization for image generation spans.

Braintrust docs status

Upstream sources

  • Google GenAI Java SDK generateImages: client.models.generateImages(String model, String prompt, GenerateImagesConfig config) — stable API, available in genai-java v1.18.0 (the version this module targets)
  • Imagen API reference: https://ai.google.dev/api/generate-images — documents prompt, config (numberOfImages, aspectRatio, negativePrompt, safetyFilterLevel, personGeneration), and generatedImages response format
  • Braintrust Python tracing: generate_images and async variants are explicitly listed as traced surfaces at https://www.braintrust.dev/docs/integrations/ai-providers/gemini

Local files inspected

  • braintrust-sdk/instrumentation/genai_1_18_0/src/main/java/com/google/genai/BraintrustApiClient.java — lines 97–113 (tagSpan input parsing: only contents/generationConfig extracted; prompt field absent); lines 116–149 (response parsing: only usageMetadata checked; missing for image responses); line 156 (hardcoded type: "llm")
  • braintrust-sdk/instrumentation/genai_1_18_0/src/test/java/dev/braintrust/instrumentation/genai/v1_18_0/BraintrustGenAITest.java — no generateImages test exists
Dominant language
Java
Stars
21
Forks
5
Avg merge
2d 7h
Merged PRs (30d)
8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from braintrustdata/braintrust-sdk-java

All issues in braintrustdata/braintrust-sdk-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.