Invalid UTF-8 / unpaired surrogates persisted in conversation state permanently break the session, and crash agent execution via google.protobuf.Value (Desktop 2.29.0)

Originally filed as google-antigravity/antigravity-cli#1478; a repository collaborator directed us to post here instead, as that repo covers only the CLI surface. Cross-posting in full so the report lives in the right place.

This also looks like the same defect class as the existing forum report Antigravity 2.6 – Agent stuck on Working due to invalid UTF-8 in CortexErrorDetails, with one difference that matters: there the failure was transient, while here the bad content is persisted, so the affected conversation is permanently broken.

Environment

  • App: Antigravity desktop app 2.29.0 (Windows x64, language_server.exe), which shares the agent core (language server + jetski/cortex executor) with the CLI. agy --version on the same machine reports CLI 1.5.3.
  • OS: Windows 11 (x64)
  • Shell: PowerShell / Windows console tooling (tool outputs frequently in legacy code pages)
  • Terminal: Antigravity desktop app (built-in)

Summary

Strings containing unpaired surrogate characters / invalid UTF-8 enter conversation state via tool error summaries and file names, are persisted verbatim, and then fail strict protobuf UTF-8 validation on every later serialization. We observed two distinct failure sites (details below). The paths involved are ones the earlier fixes do not cover: persisted conversation state and the executor’s google.protobuf.Value. All identifiers, paths and file names below are sanitized.

Steps to reproduce

As far as we can reconstruct:

  1. In a conversation, have a tool produce an error summary or result containing characters that decode to unpaired surrogates (in our case, a mis-decoded non-ASCII file name inside a tool result; on Windows, legacy-code-page tool output is a realistic source).
  2. Let the turn finish, so the content is persisted into the conversation state.
  3. Reopen the conversation.
  4. The conversation title loads, but loading the conversation state fails with invalid UTF-8; the UI retries roughly every 2 seconds, indefinitely. The conversation can never be opened again (in one case it could not be deleted from the UI either).
  5. Variant during execution: when similar content reaches a google.protobuf.Value mid-run, the executor aborts the whole run (error under Actual Behavior).

Expected behavior

Externally sourced strings (tool outputs, error summaries, file names) should be sanitized to valid UTF-8 at ingestion/persistence time (e.g. unpaired surrogates and invalid sequences replaced with U+FFFD), and a single bad string should never hard-fail protobuf marshaling for the whole session or run. Already-poisoned stored conversations should be repaired on load (sanitize-on-read) instead of remaining permanently unopenable.

Actual behavior

1. Session-state path: the conversation becomes permanently unopenable; the UI loops retrying the state load every ~2 s. No error is surfaced to the user; the view simply never finishes loading.

2. Executor path (sanitized excerpt of a real failure):

Error: agent executor error: generating and executing: proto: field google.protobuf.Value.string_value contains invalid UTF-8

| google3/third_party/gemini_coder/framework/executor/agentexecutor/agentexecutor.(*AgentExecutor).Run
| third_party/jetski/cortex/cortex.(*CascadeManager).executeOne.func1
| third_party/jetski/cortex/cortex.(*CascadeManager).executeOne.func2

Additional evidence — controlled experiment

We tested a local, reversible binary hotfix on language_server.exe (2.29.0) that lossy-replaces invalid bytes with ? at the single protobuf error site where the session-state failure occurred (length-preserving, pinned to the exact build hash, backup + one-command rollback). Result: the previously frozen conversation did load, rendered its history, and its step store kept advancing for about 3 minutes — then it stalled again when the same payload crossed a different serialization path, and a subsequent run hit the executor-path error above. Two conclusions:

  • The diagnosis (unsanitized strings persisted in conversation state) is confirmed experimentally, not just inferred.
  • Point fixes at individual marshal sites are not sufficient: the class has multiple unguarded string paths. Sanitization at ingestion/persistence, plus sanitize-on-load for existing stores, looks like the durable fix.

Independent corroboration that the app emits unpaired surrogates in its payloads: a downstream consumer of desktop-app hook payloads on the same machine hit UnicodeEncodeError: 'utf-8' codec can't encode character '\udcba' ... surrogates not allowed when encoding those payloads as UTF-8.

A downstream project has already proven the remedy pattern workable at its own boundary: the ghostel terminal’s fix for a related Antigravity output issue (dakra/ghostel, PR #778) validates strings at the boundary and falls back to a lossy decode instead of hard-failing — one bad string degrades gracefully rather than aborting everything.

Relation to earlier fixes

The Antigravity CLI 1.1.21 release notes mention fixing “the session stalling mid-response when a tool result or file diff contained invalid UTF-8”. The failures above were observed on the current desktop build (2.29.0), on paths that fix apparently does not cover.

Logs

Sanitized: account identifiers, conversation/trajectory IDs, user paths and file names removed. Fuller sanitized logs are available on request.

Hi @myler,

Welcome to the Forum,

Thank you for the thorough analysis and stack trace showing the google.protobuf.Value.string_value contains invalid UTF-8 error on Windows.

Please try the following steps:

  • Update from v2.29.0 to v2.31.0: Download the latest Antigravity v2.31.0 release from the Download page. Release v2.30.0 (Changelog) fixed an issue where Python and PowerShell commands that the agent ran on Windows could fail or produce garbled output when containing emoji or non-English characters, preventing legacy-code-page outputs from introducing invalid bytes into new turns.
  • Start a fresh conversation: Because invalid UTF-8 sequences already saved in an earlier conversation’s state file will continue to fail protobuf marshaling when loaded, start a new conversation after updating.

If the issue still occurs in a new conversation on v2.31.0, please reply here with your sanitized logs so we can escalate this to our engineering team.

Quick update and an additional data point for the team:

I also tested the latest Antigravity CLI build on Windows to see if the issue was isolated to the IDE or already patched in the CLI.

Here is what happened:

  • Chat & Context Reading: Works properly. A simple conversational query / prompt read the workspace rules (SKILL.md) and returned a response in ~9s without issue.
  • Tool Execution / File System Operations: The moment a prompt requires tool execution (for example, creating a simple teste-cli.txt file in the workspace root), it analyzes the files and immediately hangs on “Working” indefinitely.

This confirms that the CLI shares the exact same underlying Go language_server binary and triggers the same Protobuf UTF-8 serialization failure on Windows during tool/syscall execution.

Looking forward to the patch landing across both the IDE and CLI!