Skip to content

feat(engine): add tool-result clearing and approval pause timing - #254

Merged
Patel230 merged 1 commit into
mainfrom
feat/herm-adoptions
Aug 24, 2026
Merged

feat(engine): add tool-result clearing and approval pause timing#254
Patel230 merged 1 commit into
mainfrom
feat/herm-adoptions

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

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)

  • Port of herm's clearOldToolResults: at 80% of the context window, replace the content of old tool results with [output cleared] placeholders — biggest-first, keeping the most-recent clearKeepRecent (4) tool-result messages intact, and stopping once token usage drops below the threshold.
  • The tool_use blocks 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).
  • Wired into ManageContextBeforeTurn as the first context-reclaim step: clear (0.8) before compact.
  • Operates on a clone — the persisted original is never mutated in place.

2. Approval pause-timing telemetry (internal/permissions/approval_workflow.go)

  • Port of herm's approval pause tracking: ApprovalRequest now records DecisionAt (timestamp) and PauseDuration (human deliberation time, DecisionAt - CreatedAt) when a request is approved or denied, for approval-latency observability.

Verification

  • New tests: TestClearOldToolResultsNoOpWhenBelowThreshold, TestClearOldToolResultsClearsBiggestFirst, TestClearOldToolResultsStopsWhenUnderThreshold, TestClearOldToolResultsSkipsAlreadyCleared, TestApprovalRecordsPauseDuration
  • go build ./..., go vet, full engine + permissions suites green
  • Boundary guard + govulncheck + full pre-push test suite green

(Follow-ups for future PRs: herm's provider-response replay cache, graceful turn-budget exhaustion synthesis, staged skills mount.)

@Patel230
Patel230 merged commit 75a9ed8 into main Aug 24, 2026
26 checks passed
@Patel230
Patel230 deleted the feat/herm-adoptions branch August 24, 2026 09:48
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