Skip to content

[Bug]: Repeated request-local compaction summaries dominate long-session latency #1023

Closed

Description

@aptend

Existing issue check

  • Searched existing issues for compaction/summary reports; no matching issue found in the initial search.

Version and environment

Astra 0.2.11, Server + CLI Edge on Linux x86_64. The deployment was built from 2873a950f2c9fea00343757933e96070d1631596. Code references below are pinned to that deployed revision and have been checked against its Git blobs.

The affected long-running session used Kimi-K3 through an OpenAI-compatible provider, with a configured context window of 262,144 tokens and maximum completion of 65,536 tokens. The smaller context limit was required by an observed upstream context-window rejection, despite the provider catalog advertising a larger window.

Actual behavior

Once the long session enters a high-pressure compaction tier, successive tool/model rounds repeatedly invoke required_compaction using the same Kimi-K3 model. Summary generation dominates task latency.

Durable inference records for one run on 2026-10-16, during approximately 13:00–13:57 UTC+8:

Purpose Successful calls Total duration Mean duration
required_compaction 29 2,496.8 seconds 86.1 seconds
primary_agent 28 547.8 seconds 19.6 seconds

Thus approximately 82% of the successful inference duration in this sample was spent generating compaction summaries. There was also a separate compaction invocation with delivery_unknown after 201 seconds, excluded from the successful-call totals.

Example sequence, UTC+8:

  • 13:47:19–13:50:43: required compaction, approximately 203 seconds.
  • 13:50:43–13:51:01: primary model call, approximately 18 seconds.
  • 13:51:07–13:53:12: required compaction again, approximately 125 seconds.

This is a repeated-summary/latency problem. It is not a claim that every compaction produces zero token savings or that Astra never rewrites active history.

Expected behavior

After successful compaction, subsequent rounds should reuse the compacted representation and its covered-history boundary. Newly appended messages should not cause a fresh summary of substantially the same history on every provider request.

Keep the complete transcript available for audit/history, while calculating compaction pressure against the effective context that subsequent requests actually reuse. A no-op compaction should not incur another expensive summary call without a clear need.

Steps to reproduce

  1. Use Server + CLI Edge with a model having an effective context window around 262k tokens.
  2. Continue a long coding session until it enters CompactHistory or a higher compaction tier.
  3. Execute several successive tool/model rounds that append relatively small amounts of new content.
  4. Inspect durable inference invocations grouped by session, run, purpose, and creation time.
  5. Observe repeated required_compaction calls alternating with primary model calls, often taking substantially longer than the primary calls.

This was observed in a live session; a minimal deterministic reproduction is still needed.

Code evidence and suspected mechanism

The following are directly visible in the inspected code:

  1. compact_with_memoria calls generate_compact_summary(messages, ...) whenever a summary client exists and cfg.should_summarize(params.tier) holds. The condition does not require result.boundary to exist or check whether an existing summary already covers the input. The summary is returned through result.runtime_contexts.
  2. Server wire preparation uses compact_result.messages for the current provider request and adds its summary as runtime context with CurrentUserTurn lifetime. This path does not install that compacted message list as state.messages.
  3. Astra also has a distinct apply_pre_turn_summary path that really rewrites state.messages. Therefore the failure should be investigated as coordination/reuse between compaction paths, rather than absence of history compaction everywhere.
  4. record_context_compactions advances state.compact_tier_applied; the pre-turn compaction guard skips the history-rewriting path once this reaches CompactHistory. Whether that interaction contributes to this particular live sequence needs a targeted reproduction.

The suspected mechanism is that request-local summary generation repeatedly runs against a history projection whose high pressure persists, without a reusable compaction checkpoint in this path. This explains the observed alternation, but exact trigger/state transitions should be covered by a regression test.

Reference implementation and suggested validation

For comparison, Codex main 6ae8b8aa7c installs compaction results through Session::replace_compacted_history and recomputes token usage. The original audit transcript can remain separate from the active model context. This is a useful lifecycle reference, not a requirement to copy Codex's provider-specific format.

Suggested regression coverage:

  • Multiple small tool rounds after a successful compaction reuse its result instead of repeatedly summarizing the same prefix.
  • Effective context pressure decreases after adopting a compaction result.
  • New user messages, tool-call/result pairs, and required runtime authority survive compaction and resume.
  • Wire-compaction observations do not accidentally prevent a necessary active-history rewrite.
  • No-op compaction, summary failure, and cancellation have bounded retries and do not create repeated-summary loops.

No credentials, private endpoints, raw prompts, or proprietary task contents are included here.

Activity

  1. added
    kind/bug
    on Oct 16, 2026
  2. XuPeng-SH commented on Oct 20, 2026

    @XuPeng-SH
    Collaborator

    Cleanup: merged PR #1033 installs accepted summaries into canonical working history so later rounds reuse them instead of repeatedly summarizing the same history. Its #1031 continuity dependency is also merged. Closing this issue as implemented.

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

Metadata

Metadata

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions