add .hardno/ignore to skip .pi/ from reviews#1
Merged
Conversation
royosherove
added a commit
that referenced
this pull request
May 7, 2026
* perf: eliminate redundant file reads + flush model support Fix #1: Cache MemorySnapshot and fileSet in PreparedTurn. In finalizeMemoryForTurn, skip the disk re-read entirely when no tools were used during the turn (turnUsedTools=false). When tools ran, reuse the cached fileSet (avoids re-resolving paths) but still re-read file contents to detect modifications. handleStreaming() now returns { usedTools } flag. Flush model: Add config.compact.flushModel option and AgentAdapter.promptWithModel() method. When configured, memory flush turns use a cheaper/faster model (e.g. Sonnet) instead of the expensive conversation model. Pi adapter implements via session.setModel() with automatic restore after flush. All 217 tests pass, no new type errors. * perf: default flush model to Sonnet (faster) Flush turns are structured tasks (read context → write markdown) that don't need frontier reasoning. Sonnet responds 3-5x faster than Opus for these turns. Default: amazon-bedrock/us.anthropic.claude-sonnet-4-6-20250514-v1:0 Set flushModel: null in config to fall back to conversation model. * fix: address codex review — no model persistence, no complement I/O P2: Replace session.setModel() with in-memory agent.state.model swap. Avoids persisting flush model to settings.json or session log. Crash-safe: if process dies mid-flush, settings remain on user's configured model. P3: Revert complement/unknown mode pre-read. finalizeMemoryForTurn skips digest checks for complement mode, so reading files was wasted I/O. * fix: restore model unconditionally, track only file-modifying tools - Always restore agentState.model in finally (even if undefined) - Only set turnUsedTools=true for write/edit/bash/multi_edit tools (read/grep/ls/find are read-only — no need to re-hash memory files) * fix: invert tool allowlist — use read-only set instead of write set Unknown/extension tools now trigger memory re-read (safe default). Only known read-only tools (read, grep, find, ls, glob) skip re-read. Addresses codex review: custom extension tools that modify memory files would have been missed by the previous write-tool allowlist. * feat: add timing info to compact messages + persistent timing log - Telegram messages now show flush/compact/total time + model used - Timing persisted to ~/.roundhouse/logs/compact-timing.jsonl (JSONL) - Both manual /compact and auto-compact show timing * refactor: extract READ_ONLY_TOOLS + CompactResult to types, add tests - READ_ONLY_TOOLS: shared constant in memory/types.ts (not buried in handleStreaming) - CompactTiming + CompactResult: proper types in types.ts (SRP) - lifecycle.ts imports CompactResult instead of inline type - gateway.ts imports READ_ONLY_TOOLS + CompactResult from types - Tests: READ_ONLY_TOOLS membership, CompactResult with/without timing * feat: use Haiku for compact step too (compactWithModel) Before: flush used Haiku (238s) but compact restored to Opus (152s) = 390s total After: both flush AND compact use Haiku via new compactWithModel adapter method - Added compactWithModel?(threadId, modelId) to AgentAdapter interface - Implemented in pi.ts: in-memory model swap around session.compact() - lifecycle.ts: prefers compactWithModel when available, falls back to compact() * feat: live progress updates during compact (edits Telegram message in-place) - New telegram-progress.ts: createProgressMessage() → editable message handle - Compact shows: 'Flushing memory...' → 'Compacting... (flush took Xs)' → final result - Single message edited in-place (no spam of multiple messages) - Works for both manual /compact and auto-compact - Falls back gracefully for non-Telegram adapters (no-op updates) --------- Co-authored-by: Loki FastStart <loki@faststart.internal>
royosherove
added a commit
that referenced
this pull request
May 14, 2026
…31) (#133) * refactor(session-repair): beautify per code review (7 findings) Addresses all 7 findings from the post-v0.5.30 maintainability review. Pure refactor \u2014 zero behavior change. 536 tests passing (+2 new for the divergent-change fix). #1 + #7 \u2014 DRY: extract matchesErrorPatterns + fix divergent change isContextOverflowError and isToolPairingError shared ~80% of structure (top-level .message, cause-chain walk, stringify-gate, circular try/catch) but with subtle drift: only one walked the cause chain. Extracted matchesErrorPatterns(err, patterns, { stringifyGate }) shared helper. Both classifiers now ~7 lines and BOTH walk cause chains. Added 2 tests proving isToolPairingError now classifies wrapped/Bedrock-nested tool-pairing errors (regression guard for the divergent-change fix). Also extracted looksLikeValidationError() shared gate so the two classifiers don't repeat the 4xx/ValidationException check. #2 \u2014 long method: extracted buildTrimmedEntries(entries, cutIdx) from softResetSessionFile. The orchestration is now linear: validate \u2192 cut \u2192 build \u2192 repair \u2192 write \u2192 report. Each step at the same abstraction level. #3 \u2014 long catch with nested try: extracted attemptSoftResetRecovery() in lifecycle.ts. flushMemoryThenCompact catch block went from ~60 lines with nested try/catch to ~25 lines, linear: classify \u2192 recover \u2192 log \u2192 persist. #4 \u2014 magic number: MAX_CAUSE_CHAIN_DEPTH = 5 named constant. #5 \u2014 file >400 lines: split src/agents/shared/session-repair.ts (574 lines, two domains) into: - session-repair.ts (81 lines) \u2014 public surface, tool-pair repair, re-exports for backward compat - session-soft-reset.ts (120 lines) \u2014 softResetSessionFile + types - error-classifiers.ts (75 lines) \u2014 matchesErrorPatterns + isContextOverflowError + isToolPairingError + MAX_CAUSE_CHAIN_DEPTH - session-repair-internal.ts (239 lines) \u2014 shared filesystem + in-memory repair primitives All public exports preserved via re-exports (Feathers seam pattern). Existing callers compile unchanged. #6 \u2014 naming: introduced RepairResult { entries, report } named type for the previously-anonymous repairEntriesInMemory return shape. Better IDE hover/autocomplete; no inline destructuring noise at call sites. Verification: npm test \u2014 536 passing (was 534, +2 for cause-chain regression tests) wc -l src/agents/shared/session-repair.ts \u2014 81 (was 574) All public API surfaces preserved. * chore: bump to v0.5.31 + CHANGELOG --------- Co-authored-by: Roy Osherove <575051+royosherove@users.noreply.github.com>
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.
Prevents pi-hard-no from reviewing changes to .pi/ settings files.