feat(engine): add tool-result clearing and approval pause timing - #254
Merged
Conversation
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
Adopts two novel, self-contained mechanisms from the herm coding agent (github.com/aduermael/herm), ported to hawk's message/permission models with full tests.
1. Two-tier tool-result clearing (
internal/engine/compact_clear.go)clearOldToolResults: at 80% of the context window, replace the content of old tool results with[output cleared]placeholders — biggest-first, keeping the most-recentclearKeepRecent(4) tool-result messages intact, and stopping once token usage drops below the threshold.tool_useblocks are left untouched, so the model still knows what was called and can re-read files on demand. This is a gentler tier below compaction (which fires at a higher watermark).ManageContextBeforeTurnas the first context-reclaim step: clear (0.8) before compact.2. Approval pause-timing telemetry (
internal/permissions/approval_workflow.go)ApprovalRequestnow recordsDecisionAt(timestamp) andPauseDuration(human deliberation time,DecisionAt - CreatedAt) when a request is approved or denied, for approval-latency observability.Verification
TestClearOldToolResultsNoOpWhenBelowThreshold,TestClearOldToolResultsClearsBiggestFirst,TestClearOldToolResultsStopsWhenUnderThreshold,TestClearOldToolResultsSkipsAlreadyCleared,TestApprovalRecordsPauseDurationgo build ./...,go vet, full engine + permissions suites green(Follow-ups for future PRs: herm's provider-response replay cache, graceful turn-budget exhaustion synthesis, staged skills mount.)