feat(session): add compact action to session control tool - #2470
Open
1688mengdie wants to merge 2 commits into
Open
feat(session): add compact action to session control tool#24701688mengdie wants to merge 2 commits into
1688mengdie wants to merge 2 commits into
Conversation
added 2 commits
August 25, 2026 08:44
Extend the session control tool family with a rename action so a caller can rename a persisted session title through the same AgentSessionManagementPort channel used by the frontend renameChatSessionTitle. - Extend SessionControlAction with a Rename variant and as_str mapping. - Allow session_name as the required new title for rename (rejected for every other mutating action) and reject renaming the current session. - Add session_control_renamed_result_message helper for the tool result text. - Wire the Rename dispatch to reuse the upstream AgentSessionRenameRequest. - Extend the tool input schema/description and add rename validation tests. Test: cargo check -p bitfun-agent-runtime --jobs 4 EXIT 0; cargo check -p bitfun-core --jobs 4 EXIT 0; cargo test -p bitfun-agent-runtime --features agent-runtime rename --jobs 4 (7 tests pass); cargo test -p bitfun-core --features agent-runtime session_control_tool --jobs 4 (11 tests pass incl validate_rename_*). AI: lightly tested (targeted cargo check + session_control/session_control_tool unit tests).
Add the compact action to the session control tool family so a caller can compact a session context to reduce its token footprint and surface the applied compaction statistics (tokens/ratio/summary). - Thread ContextCompactionOutcome through the manual compaction task so the finished outcome is returned instead of being discarded (unit). - Add compact_session_with_outcome returning BitFunResult<ContextCompactionOutcome>; compact_session_manually delegates to it for the Desktop compatibility API. - Extend SessionControlAction with a Compact variant and its as_str mapping. - Allow compacting the caller own session (the sole self-mutation exception) while keeping owner/creator/ancestor authorization inline. - Wire the Compact dispatch to the compact engine and return the applied stats. - Extend the tool input schema/description and add compact validation tests. Test: cargo check -p bitfun-core --jobs 4 EXIT 0; cargo check -p bitfun-agent-runtime --jobs 4 EXIT 0; cargo test -p bitfun-agent-runtime --features agent-runtime compact --jobs 4 (5 tests pass); cargo test -p bitfun-core --features agent-runtime session_control_tool --jobs 4 (14 tests pass incl validate_compact_*); cargo test -p bitfun-core --features agent-runtime manual_compaction --jobs 4 (6 tests pass). AI: lightly tested (targeted cargo check + compact/session_control_tool/manual_compaction unit tests).
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
Add the
compactaction to the session control tool family so a caller can compact a session context to reduce its token footprint and surface the applied compaction statistics (tokens/ratio/summary).Changes
ContextCompactionOutcomethrough the manual compaction task so the finished outcome is returned instead of being discarded.compact_session_with_outcomereturningBitFunResult<ContextCompactionOutcome>;compact_session_manuallydelegates to it for the Desktop compatibility API.SessionControlActionwith aCompactvariant and itsas_strmapping.Compactdispatch to the compact engine and return the applied stats.Testing
AI-assisted output. Test extent: 已测 (tested).
cargo check -p bitfun-core --jobs 4EXIT 0.cargo check -p bitfun-agent-runtime --jobs 4EXIT 0.cargo test -p bitfun-agent-runtime --features agent-runtime compact --jobs 4(5 tests pass).cargo test -p bitfun-core --features agent-runtime session_control_tool --jobs 4(14 tests pass, inclvalidate_compact_*).cargo test -p bitfun-core --features agent-runtime manual_compaction --jobs 4(6 tests pass).Skipped: no full local CI — the complete build and broad test suite are covered by the repository CI against this PR. No UI change (backend tool), so no before/after screenshots; the low-risk manual verification path is to invoke the session control tool with the
compactaction against a persisted session on a dev instance.Stacked PR note
This PR is stacked on the rename PR (
pr-g6-rename-rebased). It is the second of two focused PRs for the session control tool family. The repository CI runs against this branch once the base rename PR is merged and this branch is retargeted tomain; while based on another open feature branch, the full CI is carried by the rename PR as the primary working surface.Commits
53f570bb9feat(session): add compact action to session control tool — add a compact action to the session control tool that returns the applied compaction statistics.Closes #2469