Skip to content

chat.stream_failed with "Checkpoint compaction returned an invalid anchored summary" when Codex remote compaction fails #136

Description

@wudoudouaixuexi

Title suggestion

chat.stream_failed with "Checkpoint compaction returned an invalid anchored summary" when Codex remote compaction fails

Body

Summary

When an Agent session accumulates enough context to trigger auto-compaction (Codex provider), the run frequently ends with:

Checkpoint compaction returned an invalid anchored summary; the original context was preserved {"code":"chat.stream_failed","operation":"chat"}

The message says context is preserved, but the whole chat run fails with chat.stream_failed instead of continuing with a usable handoff. This is observed repeatedly on an unstable network connection to the Codex endpoint.

Expected behavior

  • If remote compaction fails, the fallback prompt-based compaction should produce a valid summary and the conversation should continue, or at least the run should not fail with a generic chat.stream_failed.
  • The error message should be surfaced in a user-friendly way (currently the raw JSON payload is shown to the user).

Actual behavior

The chat run terminates with chat.stream_failed. The user sees the raw error payload "Checkpoint compaction returned an invalid anchored summary; the original context was preserved ...". Context is preserved but the run does not proceed.

Reproduction steps

  1. Use a Codex (ChatGPT subscription) provider in Locus.
  2. Accumulate enough context so auto-compaction triggers (≥90% of context limit, per compact::should_codex_auto_compact).
  3. Run on a network with intermittent failures toward the Codex endpoint (e.g. SSL/early-EOF errors, as observed with git pull failing with OpenSSL SSL_read: unexpected eof while reading).
  4. Observe the run fail with chat.stream_failed.

Environment

  • OS: Windows x86_64
  • Locus source branch/revision: diagnosis based on cached checkout (pull refresh failed on the same network issue); exact wording "invalid anchored summary" was not found in the cached revision, suggesting it is from a newer build
  • Provider: OpenAI Codex (ChatGPT subscription), remote compaction via POST /responses/compact
  • Unity project: 2022.3.62f3c1 (probably unrelated)

Source references used for diagnosis (cached revision)

  • src-tauri/src/agent/instance/mod.rs:6148 execute_codex_remote_compact — Codex remote compaction path; on error falls back to prompt-based compact (mod.rs:6379 "codex remote compact failed, falling back to prompt-based compact")
  • src-tauri/src/llm/codex.rs:603 compact_conversation_historyPOST /responses/compact, 300s timeout (COMPACT_REQUEST_TIMEOUT at codex.rs:549); failure modes: network error, non-2xx, non-JSON, missing compaction item
  • src-tauri/src/compact.rs:797 is_valid_compact_summary — summary validation (too short / ellipsis / too few alphanumeric chars → invalid)
  • src-tauri/src/agent/instance/mod.rs:9209chat.stream_failed emitted for any run error
  • src-tauri/src/compact.rs:151 should_codex_auto_compact — triggers at 90% context limit

Suggested improvements

  • When the fallback prompt-based summary is also invalid, distinguish "remote compaction failed" from "summary invalid" in the emitted error, and include the fallback status so users know context is safe.
  • Avoid terminating the whole run: if compaction fails, consider continuing with the preserved context (the message already claims it is preserved).
  • Surface the error in the UI instead of the raw JSON payload.

Additional notes

The same network instability (SSL early EOF) also broke git pull for the Locus source cache, so this diagnosis is based on the cached revision; please verify line numbers against the current main.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions