Skip to content

fix(cli): make auto-compact non-agentic#32

Open
BunsDev wants to merge 1 commit into
mainfrom
codex/fix-auto-compact-to-respect-user-settings
Open

fix(cli): make auto-compact non-agentic#32
BunsDev wants to merge 1 commit into
mainfrom
codex/fix-auto-compact-to-respect-user-settings

Conversation

@BunsDev
Copy link
Copy Markdown
Member

@BunsDev BunsDev commented Jun 3, 2026

Motivation

  • Prevent an unsolicited agentic turn from running during idle auto-compaction by honoring the configured auto-compact setting and threshold.
  • Ensure compaction uses the dedicated non-agentic summarisation path so injected transcript content cannot drive tool execution.

Description

  • Read and apply the effective compact threshold from the live config into the TUI state (app.auto_compact_threshold) and respect app.auto_compact_enabled before triggering compaction.
  • Replace the previous idle-path that appended a synthetic user message and dispatched run_query_loop with a direct call to the non-agentic summariser compact_conversation, which does not advertise or execute tools.
  • Run the summarisation in a background task with cancellation handling and update the shared messages/cursor state on completion while preserving existing UI state guards (app.is_streaming, app.auto_compact_running, status messages, session save).

Testing

  • cargo check -p claurst --no-default-features — passed.
  • cargo check --workspace — could not complete in this environment due to missing system alsa dev files required by alsa-sys/cpal (external system dependency).
  • cargo clippy -p claurst --no-default-features --all-targets -- -D warnings — not green due to pre-existing clippy warnings outside the scope of this change.

Codex Task

Copilot AI review requested due to automatic review settings June 3, 2026 11:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the CLI TUI’s idle auto-compaction behavior to honor the configured auto-compact enablement/threshold and to avoid triggering an agentic query-loop turn by using the dedicated non-tool compaction path.

Changes:

  • Sync the effective compaction threshold from config into TUI state (app.auto_compact_threshold) and gate idle auto-compact on app.auto_compact_enabled.
  • Replace the idle-path “synthetic user message + run_query_loop” flow with a direct call to claurst_query::compact_conversation in a background task.
  • Improve status messaging around auto-compaction initiation/completion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3054 to 3058
let compact_model =
claurst_api::effective_model_for_config(&cmd_ctx.config, &model_registry);
let client_clone = client.clone();
app.is_streaming = true;

Comment on lines 3057 to 3058
app.is_streaming = true;

Comment on lines +3060 to 3069
if ct.is_cancelled() {
return QueryOutcome::Cancelled;
}

let msgs = msgs_arc_clone.lock().await.clone();
match claurst_query::compact_conversation(
client_clone.as_ref(),
&mut msgs,
tools_arc_clone.as_slice(),
&ctx_clone,
&qcfg,
tracker,
Some(tx),
ct,
None,
&msgs,
&compact_model,
)
Comment on lines +3032 to +3036
// Auto-compact: when enabled and context usage reaches the configured
// threshold with no query running, summarize through the dedicated
// no-tools compaction path instead of starting an agentic turn.
if app.auto_compact_enabled
&& app.context_window_size > 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants