Skip to content

v2.1.0 — Gemini 4 Argon Support, Long Decode & Resumable SSE Streams

Latest

Choose a tag to compare

@github-actions github-actions released this 14 Oct 09:58
· 1 commit to main since this release

Gemini Interactions API Java SDK v2.1.0

This release introduces full support for Gemini 4 Argon (gemini-4-argon), its unified 1M-token context window, server-managed Long Decode (> 64K output tokens), Thinking levels (ThinkingLevel.MEDIUM), and resumable Server-Sent Events (SSE) streams for background interactions.


🚀 Key Highlights

🧠 Gemini 4 Argon Support (gemini-4-argon)

Use Google's latest frontier model across both direct model interactions and autonomous Antigravity agent reasoning:

  • Model Constant: Added ModelOption.GEMINI_4_ARGON ("gemini-4-argon").
  • Unified 1M Context Window: Supports up to 1,048,576 tokens in a single unified pool shared across input, thinking, and output tokens (total_tokens = input_tokens + thought_tokens + output_tokens <= 1,048,576).
  • Thinking Levels (Config.ThinkingLevel): Added ThinkingLevel.MEDIUM (the default reasoning level for Gemini 4 Argon). On the Interactions API, Gemini 4 Argon supports LOW, MEDIUM, and HIGH (while Flash and Flash-Lite models additionally support MINIMAL).
  • Antigravity Agent Reasoning: Configure Antigravity agents to run with Gemini 4 Argon via AntigravityAgentConfig.builder().model(ModelOption.GEMINI_4_ARGON).
ModelInteractionParams params = ModelInteractionParams.builder()
    .model(ModelOption.GEMINI_4_ARGON)
    .input("Prove the fundamental theorem of algebra and provide geometric intuition.")
    .generationConfig(GenerationConfig.builder()
        .thinkingLevel(ThinkingLevel.HIGH)
        .thinkingSummaries(ThinkingSummaries.AUTO)
        .maxOutputTokens(32_768)
        .build())
    .build();

Interaction interaction = client.create(params);
System.out.println(interaction.outputText());

📜 Server-Managed Long Decode (> 64K Output Tokens)

Gemini 4 Argon supports generating well beyond 65,536 output tokens in a single interaction using server-managed Long Decode:

  • Seamless Multi-Hop Output Assembly: When maxOutputTokens > 65_536 is requested with .background(true), the server automatically executes multiple decode hops (ModelOutputStep entries in interaction.steps()). interaction.outputText() now automatically concatenates text across all consecutive ModelOutputStep hops (ignoring any interleaved ThoughtSteps) into a single continuous string.
  • Step-Level Token Usage: Events.StepStop now exposes stepUsage() (step_usage) for the individual decode hop alongside usage() for cumulative interaction token consumption.
ModelInteractionParams longDecodeParams = ModelInteractionParams.builder()
    .model(ModelOption.GEMINI_4_ARGON)
    .input("Write a comprehensive, multi-chapter specification and full implementation...")
    .background(true) // Required when maxOutputTokens > 65,536
    .generationConfig(GenerationConfig.builder()
        .thinkingLevel(ThinkingLevel.HIGH)
        .maxOutputTokens(200_000)
        .build())
    .build();

Interaction interaction = client.create(longDecodeParams);
while (!interaction.status().isFinished()) {
    Thread.sleep(5000);
    interaction = client.get(interaction.id());
}

// Automatically concatenates text across all Long Decode ModelOutputStep hops
String fullDocument = interaction.outputText();

📡 Background Execution & Resumable SSE Streams

Stream in-progress background interactions and seamlessly recover from dropped network connections without losing or duplicating events:

  • client.stream(String interactionId): Open an SSE stream (GET /v1beta/interactions/{id}?stream=true) for an existing background interaction.
  • client.stream(String interactionId, String lastEventId): Resume an interrupted SSE stream from the last received event.eventId() (last_event_id query parameter), replaying only subsequent events.
Interaction started = client.create(
    AgentInteractionParams.builder()
        .agent(AgentOption.ANTIGRAVITY_PREVIEW_09_2026)
        .agentConfig(AntigravityAgentConfig.builder()
            .model(ModelOption.GEMINI_4_ARGON)
            .maxTotalTokens(500_000L)
            .build())
        .input("Refactor the repository and run the full test suite.")
        .background(true)
        .build());

String lastEventId = null;
try (Stream<Events> events = client.stream(started.id(), lastEventId)) {
    for (Events event : (Iterable<Events>) events::iterator) {
        if (event.eventId() != null) {
            lastEventId = event.eventId();
        }
        // Process SSE events; if disconnected, reconnect with client.stream(started.id(), lastEventId)
    }
}

🔄 OpenAPI Specification Sync & SDK Enhancements

  • Local Environment Variables: Added env (Map<String, Object>) and a fluent LocalEnvironmentConfig.Builder (env(key, value), envCredential(key, credentialId)) to LocalEnvironmentConfig.
  • Documentation & Agent Skill: Updated README.md and skills/gemini-interactions-java-api/SKILL.md with Gemini 4 Argon guidance, Long Decode recipes, SSE stream resumption, and checkpoint continuation via continuationToken.
  • Internal & CI Improvements: Hardened stream lifecycle handling, webhook cryptographic comparison, and test resilience against transient API rate limits.

📦 Artifacts Published to Maven Central

<dependency>
    <groupId>io.github.glaforge</groupId>
    <artifactId>gemini-interactions-api-sdk</artifactId>
    <version>2.1.0</version>
</dependency>
  • io.github.glaforge:gemini-interactions-parent:2.1.0
  • io.github.glaforge:gemini-interactions-api-sdk:2.1.0
  • io.github.glaforge:gemini-interactions-server:2.1.0

Full Changelog: v2.0.0...v2.1.0