Skip to content

Comments

fix(agent): protect bootstrap prefix from context pruning#381

Closed
maxsumrall wants to merge 1 commit intoopenclaw:mainfrom
maxsumrall:max/context-pruning
Closed

fix(agent): protect bootstrap prefix from context pruning#381
maxsumrall wants to merge 1 commit intoopenclaw:mainfrom
maxsumrall:max/context-pruning

Conversation

@maxsumrall
Copy link
Contributor

@maxsumrall maxsumrall commented Jan 7, 2026

Follow-up safety fix for the opt-in tool-result context pruning that recently landed on main.

What changed

  • Never prune anything before the first role:"user" message in the session (“bootstrap prefix” protection).

Why

Some sessions start with assistant/tool bootstrap work (reading user/system files, etc) before the first user message. In aggressive pruning, those early tool results can get cleared even though they function as part of the initial context, leading to missing details later.

Notes

  • Still in-memory only (context hook); session *.jsonl history remains complete.
  • No config changes.
  • PR diff is small because the base pruning feature + tests/docs were pushed directly to main after this PR was opened; this PR now only adds the bootstrap-prefix guard.

Testing

  • pnpm lint && pnpm build && pnpm test

@maxsumrall maxsumrall force-pushed the max/context-pruning branch from 9753a5e to 91a7b2a Compare January 7, 2026 11:20
@maxsumrall maxsumrall marked this pull request as ready for review January 7, 2026 11:26
@maxsumrall maxsumrall force-pushed the max/context-pruning branch 6 times, most recently from a0faff2 to d1cd565 Compare January 7, 2026 15:14
@maxsumrall
Copy link
Contributor Author

Quick update since earlier today:

  • Switched config from enabled: true to mode: "adaptive" | "aggressive".

    • Why: it makes intent explicit and avoids “magic values” (like setting ratios to 0) to get always-prune behavior.
  • Replaced the earlier env-var-based wiring with a per-session WeakMap runtime registry.

    • Why: the env var approach was process-global and could leak settings across concurrent sessions in the gateway.
  • Removed all context-pruning debug logging.

    • Why: it was adding custom session.jsonl entries + extra config knobs. Keeping the feature focused + low-noise should make it easier to review and upstream.

Behavior is still the same core promise: pruning happens only in-memory in the Pi context hook; the session *.jsonl on disk stays untouched/complete.

@maxsumrall
Copy link
Contributor Author

I took a look at #386 ("observation masking"). It’s aiming at the same root problem (tool results dominating context), but there are a few important differences vs this PR:

Net: #386 is simpler and very predictable, but it’s also easier to accidentally over-prune “still-needed” tool outputs and it adds more churn to the embedded runner. This PR’s aggressive mode gives you the simple/always-prune path while keeping the cutoff anchored to assistant messages and keeping the runner wiring minimal.

@maxsumrall maxsumrall force-pushed the max/context-pruning branch 2 times, most recently from 2c81d5c to 8b36001 Compare January 7, 2026 16:37
@maxsumrall maxsumrall force-pushed the max/context-pruning branch from 96a9d68 to d538333 Compare January 7, 2026 17:21
@maxsumrall maxsumrall changed the title feat(agent): opt-in tool-result context pruning fix(agent): protect bootstrap prefix from context pruning Jan 7, 2026
@steipete steipete self-assigned this Jan 7, 2026
steipete added a commit that referenced this pull request Jan 7, 2026
@steipete
Copy link
Contributor

steipete commented Jan 7, 2026

Landed on main.

Commits:

Tests: pnpm lint && pnpm build && pnpm test

@steipete steipete closed this Jan 7, 2026
dgarson added a commit to dgarson/clawdbot that referenced this pull request Feb 9, 2026
* fix: improve debug logging for Graphiti client and startup service URLs

- Add URL to Graphiti client error logs for ingest and search operations
- Log configured external service endpoints (Graphiti, Obsidian, QMD) at startup
- Helps debug connectivity issues by showing which URLs are being targeted

* feat: add Goal Progress Panel to Overseer view

New component that provides detailed per-phase progress tracking for goals:
- Overall goal completion percentage with animated progress bar
- Status distribution visualization (done/in-progress/blocked/pending)
- Per-phase collapsible progress bars with stacked status segments
- Individual task listing with dependency indicators
- Velocity metrics (tasks/day) and estimated time remaining

Files added:
- ui/src/ui/views/overseer-progress.ts — Goal progress panel component
- ui/src/styles/overseer.css — Extracted overseer styles + new progress panel CSS

Integration:
- Added expandedPhaseIds state + toggleProgressPhase to overseer controller
- Wired renderGoalProgress into main overseer view (shows when goal has plan)
- Added CSS import to main styles.css
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.

2 participants