github genkit-ai/genkit genkit@1.43.0
Genkit JS 1.43.0

3 hours ago

Highlights

Agents that recover from failures, plus background sub-agents

Agent runs can now pick up where they stopped after a failure or an abort, and orchestrators can hand work to sub-agents that run in the background.

  • throwOnError: false on generate() returns the failure and the conversation up to the last completed tool round, so you can retry from there. Code that doesn't set it still gets the same errors as before. (#6359)

    const opts = { model: googleAI.model('gemini-flash-latest'), tools: [getWeather], throwOnError: false };
    let res = await ai.generate({ ...opts, prompt: 'What should I wear in Tokyo today?' });
    if (res.finishReason === 'failed' || res.finishReason === 'aborted') {
      res = await ai.generate({ ...opts, messages: res.messages });
    }
  • Failed and aborted agent turns are now resume points. A failed turn is saved as a failed snapshot and a stopped run is saved as an aborted snapshot. Both can be resumed. (#6361, #6362, #6360)

  • waitForSnapshot is the blocking version of getSnapshot. It waits on the server until a detached turn finishes, so you don't need a polling loop. (#6272)

    const task = await reportAgent.chat().detach('Write the report');
    const snap = await task.wait();
  • Background delegation in the agents middleware. With async: true, delegation tools accept background: true and return a task ID right away. New check_background_tasks, wait_for_background_tasks and abort_background_tasks tools let the orchestrator manage those tasks. (#6273)

    use: [agents({ agents: ['researcher'], async: true })]
  • continue_task continues a failed, aborted or finished sub-agent task from its handle, with optional new instructions. Snapshot reads also accept metadataOnly to skip loading the state. (#6693)

  • Transport-specific options in AgentAPI. In-process agents accept a per-chat or per-call context, so auth carries through detached tasks and background jobs. The building blocks for custom AgentTransport implementations are now exported. (#6448)

    const chat = weatherAgent.chat({}, { context: { auth: { uid: 'alice' } } });

New contextCompression middleware

@genkit-ai/middleware now includes contextCompression, which keeps long agent conversations within a token budget. It truncates tool responses, removes duplicate tool responses, caps message counts, and can summarize old turns with an LLM. It tracks compaction history so later rounds build on earlier ones. (#6266, #6267, #6269, #6270)

use: [
  contextCompression({
    maxInputTokens: 80000,
    deduplicateToolResponses: { matchBy: 'name-and-input' },
    toolResponses: { maxChars: 2000, preserveRecent: 2 },
    summarize: { model: googleAI.model('gemini-flash-lite-latest'), preserveRecent: 6 },
  }),
]

Gemini: Interactions API, Gemini 4 Argon, Omni and more

  • The googleAI plugin now sends requests for -latest aliases, newer Gemini models and any model it doesn't know to the Interactions API. Older built-in models stay on generateContent. (#6344)
  • The vertexAI plugin routes the same way, with one difference: image models and the -latest aliases stay on generateContent. (#6851)
  • New models: gemini-4-argon, gemini-3.8-flash, gemini-3.8-flash-tts, gemini-3.8-flash-lite-tts, gemini-nano-banana-2.1, gemini-omni-1.1-flash (replaces Veo 3.1), lyria-3.5 and antigravity-preview-09-2026. Gemini 2.5 and the retiring preview models are now hidden: they still work but no longer show up in autocomplete. (#6807)
  • vertexAI gets the same model updates, plus text-to-speech, Omni video generation and the gemini-embedding-2 embedder. (#6859)

Breaking for models on the Interactions API: response.raw/custom now has a different shape. safetySettings, toolConfig, thinkingBudget and candidates > 1 are dropped or rejected, and system messages must be text-only. See the #6344 description for the full list.

Pluggable instrumentation and the new @genkit-ai/otel plugin

Telemetry is now built on pluggable Instrumentation providers instead of being tied to OpenTelemetry. By default nothing changes. The Developer UI no longer needs the OTel SDK, and logs now show up next to traces. (#6336)

The new @genkit-ai/otel package (0.2.0) emits spans that follow the OpenTelemetry GenAI semantic conventions. (#6340)

import { configureInstrumentation } from 'genkit/tracing';
import { GenAiInstrumentation } from '@genkit-ai/otel';

new NodeSDK().start();
configureInstrumentation(new GenAiInstrumentation({ contentCapturingMode: 'SPAN_ONLY', emitToolSpans: true }));

Reflection API outside dev mode, with optional auth

The reflection API can now run without the rest of dev mode, and you can protect it with a shared secret. (#6454, #6666)

GENKIT_REFLECTION_ENABLED=true \
GENKIT_REFLECTION_HOST=0.0.0.0 \
GENKIT_REFLECTION_PORT=3100 \
GENKIT_REFLECTION_SECRET_TOKEN=$(openssl rand -base64 32) \
node lib/index.js
  • genkit({ reflectionPort: 3200 }) binds exactly that port and fails if it's taken. reflectionPort: 0 lets the OS pick a port. Leaving it unset still searches upward from 3100.
  • GENKIT_REFLECTION_ENABLED=false turns the API off even under GENKIT_ENV=dev. Any value other than true or false throws from genkit().

Features

OpenAI-compatible (compat-oai)

  • Added gpt-6-astra and the gpt-5.6 models to the OpenAI catalog. (#6303, #6357)
  • New strict config option for structured outputs. It maps to response_format.json_schema.strict. (#5886)

Bug Fixes

Core / AI

  • Nested dotprompt partials are now named by their path (for example support/_system), so partials with the same name in different folders no longer collide. Existing {{> system}} references still work when the short name is unique. (#5410)

Middleware (contextCompression)

  • Fixed several edge cases:

    • inputTokens is now set on candidates[0].message. (#6527)
    • Duplicate parallel tool responses are matched correctly. (#6530)
    • Character limits are enforced on multipart tool responses. (#6532)
    • preserveRecent no longer drops messages when summarization is skipped. (#6533)
    • Short histories that are over budget now fall back correctly. (#6565)
  • Ported six fixes from the Go implementation. They cover a lost anchor message on re-compaction, maxMessages: 1 sending no conversation, the token-budget fallback being skipped, and more accurate token estimates for tool responses. (#6726)

  • Documented the missing contextCompression options. (#6600)

Google GenAI

  • TTS models no longer report support for constrained output. (#6341)
  • Fixed the Vertex multimodal embedding dimensions. (#6484)

Anthropic

  • Empty signed thinking blocks are now sent back to the API instead of being dropped. (#6838)

OpenAI-compatible (compat-oai)

  • Assistant text is kept when the same message also contains tool calls. (#6792)

New Contributors

Full Changelog: https://github.com/genkit-ai/genkit/compare/genkit@1.42.0...genkit@1.43.0

Don't miss a new genkit release

NewReleases is sending notifications on new releases.