Skip to content

fix(session): invalidate token usage after pruning tool output - #999

Open
lewismosciski wants to merge 1 commit into
modelscope:mainfrom
lewismosciski:fix/pruned-context-token-usage
Open

lewismosciski wants to merge 1 commit into
modelscope:mainfrom
lewismosciski:fix/pruned-context-token-usage

Conversation

@lewismosciski

Copy link
Copy Markdown

Change Summary

Tool-output pruning retains later assistant usage measured over the original output. The next strategy therefore still sees the old token count and can call the summary model even when pruning brought the context below its limit.

Discard those stale usage fields from the pruned view. Keep measurements preceding the first pruned output, and preserve the original session records.

Validation: three regressions failed before the fix; 153 related tests passed afterward, with 20 skips. The assembler regression verifies that no summary call occurs and the corrected view survives reopening the session. Applicable changed-file pre-commit hooks passed. Full-repository pre-commit still reports existing lint/format failures on main, including skills_manager.py:61 and shell_validator.py:91.

Related issue number

Found while inspecting the default context-compaction pipeline; no existing issue.

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Run pre-commit install and pre-commit run --all-files before git commit, and passed lint check. (Both run; existing repository failures noted above.)
  • Documentation reflects the changes where applicable (internal fix; no API or configuration change)

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant