feat(tool): port openclaude context primitives - #252
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 four self-contained, stdlib-only context/robustness mechanisms from the OpenClaude coding agent (github.com/Gitlawb/openclaude), ported to idiomatic Go with full tests. None existed in hawk before.
1.
internal/circuitbreaker— closed/open/half-open circuit breaker with cooldown (port of OpenClaude's auto-compact breaker: 3 failures -> cooldown -> half-open probe that a single failure re-opens, a single success closes). Time-injected, concurrency-safe. hawk's AutoCompactor already has a simpler consecutive-failure guard; this is the generalized primitive with cooldown + auto half-open retry.2.
internal/smartrouting— deterministic simple/strong turn classifier (port of OpenClaude smart routing): cheap model for trivial turns, strong for anything non-trivial, always fail-toward-strong so a misroute never degrades a hard answer. Pure function, word-boundary keyword matching.3.
internal/conversationarc— durable sidecar memory of goals/decisions/milestones/phase (init->exploring->implementing->reviewing->completed), persisted to.arc.json, with a byte-stable model-visible summary (volatile timestamps normalized so unchanged arcs don't rewrite).4.
internal/relevanceprune— token-budgeted context pruning that scores older messages by keyword overlap with the task context, keeps highest-relevance groups up to budget, and always preserves the recent tail + tool calls + errors.All boundary-compliant (zero
eyrie/clientimports, stdlib-only). README adopted-capabilities table updated.Verification
go build ./...,go vet, full./internal/{circuitbreaker,smartrouting,conversationarc,relevanceprune}suites green