Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Jan 12, 2026

Summary

When Gemini API errors occur (like INVALID_ARGUMENT with code 400), the error messages are too vague to diagnose the root cause. This PR adds diagnostic properties to the captureException() call in the Gemini handler's createMessage() method.

Problem

A PostHog error showed only:

ApiProviderError: {
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT"
  }
}

This provides no information about which argument is invalid or what caused the issue.

See original PostHog issue: https://us.posthog.com/error_tracking/019bb205-1968-7581-b2c9-9b7f27537d3d

Solution

Add diagnostic properties to the telemetry capture:

Property Purpose
messageCount Number of input messages
geminiContentsCount Number of converted Gemini contents
hasToolUseBlocks Whether messages contain tool_use blocks
hasToolResultBlocks Whether messages contain tool_result blocks
hasImageBlocks Whether messages contain image blocks
emptyPartsCount Count of contents with empty parts (likely cause of INVALID_ARGUMENT)
toolIdToNameSize Size of tool ID→name mapping
hasThinkingConfig Whether thinking configuration is enabled
usingNativeTools Whether native tools are in use
includeThoughtSignatures Whether thought signatures are included

Testing

  • All 17 Gemini tests pass
  • Full test suite passes (371 passed, 4 skipped)

Linear Issue

Resolves ROO-515


Important

Adds diagnostic properties to GeminiHandler.createMessage() telemetry for better error context in API errors.

  • Behavior:
    • Adds diagnostic properties to captureException() in GeminiHandler.createMessage() for better error context.
    • Properties include messageCount, geminiContentsCount, hasToolUseBlocks, hasToolResultBlocks, hasImageBlocks, emptyPartsCount, toolIdToNameSize, hasThinkingConfig, usingNativeTools, includeThoughtSignatures.
  • Testing:
    • Updates gemini.spec.ts to verify diagnostic properties in telemetry capture for createMessage errors.
    • All 17 Gemini tests pass; full suite: 371 passed, 4 skipped.

This description was created by Ellipsis for 16529b7. You can customize this summary. It will automatically update as commits are pushed.

When Gemini API errors occur, the error messages are often too vague to diagnose
the root cause. This change adds diagnostic properties to the captureException()
call in the Gemini handler's createMessage() method.

Properties added:
- messageCount: Number of input messages
- geminiContentsCount: Number of converted Gemini contents
- hasToolUseBlocks: Whether messages contain tool_use blocks
- hasToolResultBlocks: Whether messages contain tool_result blocks
- hasImageBlocks: Whether messages contain image blocks
- emptyPartsCount: Count of contents with empty parts (likely cause of INVALID_ARGUMENT)
- toolIdToNameSize: Size of tool ID→name mapping
- hasThinkingConfig: Whether thinking configuration is enabled
- usingNativeTools: Whether native tools are in use
- includeThoughtSignatures: Whether thought signatures are included

Resolves ROO-515
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners January 12, 2026 23:09
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. Enhancement New feature or request labels Jan 12, 2026
@roomote
Copy link
Contributor

roomote bot commented Jan 12, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues identified.

The PR correctly adds diagnostic properties to the Gemini error telemetry. All variables are properly scoped, the telemetry service signature is compatible, and test coverage is adequate.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants