Repository navigation
Emit and render threshold and manual compaction events - #765
Open
baixinghao wants to merge 1 commit into
Open
baixinghao wants to merge 1 commit into
baixinghao wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #506.
Threshold-based automatic compaction ran silently: when the context estimate crossed the auto-compact threshold,
CodingSessionissued the summarization request at a turn boundary with no events at all, so the TUI showed a finished answer followed by an unexplained spinner. Only the overflow path emittedCompactionStartEvent/CompactionEndEvent, even thoughCompactionReasonalready defines"manual" | "threshold" | "overflow".Changes
src/tau_coding/session.py_maybe_auto_compactinto_auto_compact_plan()(threshold + plan checks) and_auto_compact_events()(execution). The latter is an async generator that yieldsCompactionStartEvent(reason="threshold")andCompactionEndEvent(reason="threshold", ...)around a real compaction run, and also forwards them to the extension runtime — mirroring how the overflow path both yields and emits. No plan means no events, so routine threshold checks stay silent.CompactionEndEvent(reason="threshold", aborted=True, error_message=...), so failures are observable instead of only appearing in the diagnostic log.auto_compact_before_prompt,auto_compact_after_prompt,auto_compact_after_continue) forward the events into the prompt/continue streams. Compaction stays inside the enclosing turn: no extraAgentSettledEvent, so no extra turn-finished notification.compact_detailed()(manual compaction) now emitsCompactionStartEvent(reason="manual")/CompactionEndEvent(reason="manual", ...)through the extension runtime, including an aborted end event on failure, so extensions and non-TUI frontends get one consistent signal for every compaction kind. The TUI's own/compactflow is unchanged.TUI rendering (
tui/adapter.py,tui/app.py)… Compacting contexttranscript status item explains the post-answer wait while threshold compaction runs.… Auto-compaction failed: <error>instead of passing silently.Docs (
website/content/guides/context.md): document the new status items.Tests
test_threshold_auto_compaction_emits_exactly_one_start_end_pair— one adjacent start/end pair withreason="threshold"across the prompts that trigger compaction, and exactly oneAgentSettledEventper prompt.test_auto_compact_check_without_work_emits_no_compaction_events— threshold checks that find no work emit nothing.test_threshold_auto_compaction_failure_emits_aborted_end_event— a failing summary provider yields an aborted end event with the error message, the turn still completes, and nothing is persisted.test_manual_compaction_emits_events_for_extensions— manual compaction emits one start/end pair withreason="manual"and the result attached.test_tui_adapter_renders_threshold_compaction_status— status item on start, silence on success, failure status on aborted end.test_tui_prompt_worker_explains_threshold_compaction_pause— end-to-end prompt-worker flow: answer renders, compaction status explains the pause, running state and notification bookkeeping stay owned by the turn.uv run pytest tests/test_coding_session.py tests/test_tui_adapter.py tests/test_tui_app.pypasses;ruff check/ruff format --check/mypyare clean on the touched files.Note: this Windows checkout has ~40 pre-existing test failures on a clean
main(TUI layout, updater, file-drop path handling, etc.). The failure list before/after this change is identical — no regressions.