Skip to content

fix(compaction): make overflow tuning configurable#80889

Open
hyspacex wants to merge 1 commit into
openclaw:mainfrom
hyspacex:fix/80638-80639-compaction-knobs
Open

fix(compaction): make overflow tuning configurable#80889
hyspacex wants to merge 1 commit into
openclaw:mainfrom
hyspacex:fix/80638-80639-compaction-knobs

Conversation

@hyspacex

@hyspacex hyspacex commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add agents.defaults.compaction.preemptiveOverflowRatio for Pi tool-loop preemptive overflow threshold tuning
  • add agents.defaults.compaction.maxOverflowAttempts for Pi overflow compaction retry tuning
  • preserve current defaults (0.9 ratio, 3 overflow retries) and document schema labels/help text

Fixes #80638
Fixes #80639

Real behavior proof

  • Behavior or issue addressed: Pi compaction overflow tuning is now configurable instead of hardcoded: configured values are accepted by the config schema and used by runtime resolver helpers, while unset config preserves the old defaults.
  • Real environment tested: Harry's Mac mini, Darwin 25.4.0 arm64, Node v22.22.0, local OpenClaw checkout on branch fix/80638-80639-compaction-knobs.
  • Exact steps or command run after this patch:
node --import tsx - <<'EOF'
import { resolveMaxOverflowCompactionAttempts, resolvePreemptiveOverflowRatio } from './src/agents/pi-embedded-runner/compaction-runtime-config.ts';
import { AgentDefaultsSchema } from './src/config/zod-schema.agent-defaults.ts';

const config = { agents: { defaults: { compaction: { preemptiveOverflowRatio: 0.72, maxOverflowAttempts: 1 } } } };
const parsed = AgentDefaultsSchema.parse(config.agents.defaults);
console.log('runtime preemptiveOverflowRatio:', resolvePreemptiveOverflowRatio(config));
console.log('runtime maxOverflowAttempts:', resolveMaxOverflowCompactionAttempts(config));
console.log('schema preserved preemptiveOverflowRatio:', parsed.compaction?.preemptiveOverflowRatio);
console.log('schema preserved maxOverflowAttempts:', parsed.compaction?.maxOverflowAttempts);
console.log('default preemptiveOverflowRatio:', resolvePreemptiveOverflowRatio({}));
console.log('default maxOverflowAttempts:', resolveMaxOverflowCompactionAttempts({}));
EOF
  • Evidence after fix: terminal output from the real local checkout:
runtime preemptiveOverflowRatio: 0.72
runtime maxOverflowAttempts: 1
schema preserved preemptiveOverflowRatio: 0.72
schema preserved maxOverflowAttempts: 1
default preemptiveOverflowRatio: 0.9
default maxOverflowAttempts: 3
  • Observed result after fix: Configured values (0.72, 1) are parsed and resolved at runtime; default behavior remains 0.9 and 3 when unset.
  • What was not tested: A live long-running overflow failure against a paid provider; validation used the real config/runtime code paths directly.

Validation

  • node scripts/test-projects.mjs src/agents/pi-embedded-runner/compaction-runtime-config.test.ts src/config/config.compaction-settings.test.ts src/config/schema.help.quality.test.ts
  • pnpm -s config:schema:check
  • pnpm -s check:test-types

@clawsweeper

clawsweeper Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed May 28, 2026, 12:55 AM ET / 04:55 UTC.

Summary
The PR adds two optional compaction overflow config keys, wires them into Pi overflow retry and preemptive guard resolution, and adds schema/help/tests while preserving existing defaults.

PR surface: Source +47, Tests +64. Total +111 across 11 files.

Reproducibility: yes. for the source condition: current main still hardcodes max overflow attempts to 3 and the tool-result guard ratio to 0.9. I did not reproduce the reported long-running paid-provider overflow loop, but the missing config knobs are clear from source inspection.

Review metrics: 1 noteworthy metric.

  • Config surfaces: 2 added, 0 changed, 0 removed. Two new agents.defaults.compaction.* keys become operator-facing config and need maintainer-approved docs and upgrade expectations.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Rebase onto src/agents/embedded-agent-runner/** and refresh affected tests.
  • [P2] Add public docs for both config keys, including ranges, defaults, and 0 retry behavior.
  • [P2] Get maintainer sign-off on the new public compaction config surface.

Risk before merge

  • [P1] The two new agents.defaults.compaction.* keys become a public operator config contract, so maintainers need to approve their names, ranges, defaults, and support expectations before merge.
  • [P1] The branch is dirty against current main because the runner path is now src/agents/embedded-agent-runner/** while the PR targets the older src/agents/pi-embedded-runner/**.
  • [P1] Public docs currently omit the proposed knobs, so users would only discover the behavior through schema/help output.

Maintainer options:

  1. Approve, document, and rebase the knobs (recommended)
    If maintainers want this contract, update the branch to current src/agents/embedded-agent-runner/**, document both keys/ranges/defaults, and keep tests proving unset defaults stay 0.9/3.
  2. Accept schema-help-only discoverability
    Maintainers can intentionally accept the expert-only discoverability risk after the branch is clean, but that leaves the public config docs incomplete.
  3. Defer public compaction tuning
    If these cost-control knobs need broader design, pause or close this PR and keep the linked issues as compaction policy discussion.

Next step before merge

  • [P2] A maintainer needs to approve whether these operator knobs belong in the public config contract before deciding whether to repair the dirty branch or request a rebased/docs-updated revision.

Security
Cleared: The diff changes compaction runtime/config/schema/docs-help/test files only and does not add dependencies, workflows, lockfiles, credential handling, or executable supply-chain surface.

Review findings

  • [P3] Document the public compaction knobs — src/config/zod-schema.agent-defaults.ts:181-182
Review details

Best possible solution:

Land a rebased version only after maintainers accept the two new agents.defaults.compaction.* knobs, docs cover their ranges/defaults, and unset config continues to preserve the 0.9 ratio and 3 retry defaults.

Do we have a high-confidence way to reproduce the issue?

Yes for the source condition: current main still hardcodes max overflow attempts to 3 and the tool-result guard ratio to 0.9. I did not reproduce the reported long-running paid-provider overflow loop, but the missing config knobs are clear from source inspection.

Is this the best way to solve the issue?

Unclear until maintainers approve the new public config contract. The implementation shape is narrow and preserves defaults, but it must target the current embedded runner path and add public docs before it is the best merge path.

Full review comments:

  • [P3] Document the public compaction knobs — src/config/zod-schema.agent-defaults.ts:181-182
    Adding these schema fields makes them supported config, but neither docs/gateway/config-agents.md nor docs/reference/session-management-compaction.md documents the names, ranges, defaults, or how maxOverflowAttempts: 0 changes overflow recovery. Please add public docs with the same defaults/ranges as the schema/help copy.
    Confidence: 0.93

Overall correctness: patch is correct
Overall confidence: 0.84

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against f7c32fc8befd.

Label changes

Label justifications:

  • P2: This is a normal-priority compaction configurability improvement for long-running agent overflow cost/control with limited runtime surface.
  • merge-risk: 🚨 compatibility: The PR adds new public agents.defaults.compaction.* config keys, creating operator-visible defaults that need approved docs and upgrade expectations.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes terminal output from a real local checkout showing schema parsing and runtime resolver values/defaults after the patch.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal output from a real local checkout showing schema parsing and runtime resolver values/defaults after the patch.
Evidence reviewed

PR surface:

Source +47, Tests +64. Total +111 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 8 50 3 +47
Tests 3 64 0 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 114 3 +111

What I checked:

Likely related people:

  • steipete: Blame on the latest release and current-main snapshot attributes the central overflow compaction constants, guard ratio, and compaction schema snapshot to Peter Steinberger, making him a likely routing candidate for compaction config policy. (role: recent area contributor; confidence: medium; commits: 10ad3aa16068, 1f1cdd84ea24; files: src/agents/pi-embedded-runner/run.ts, src/agents/embedded-agent-runner/run.ts, src/agents/embedded-agent-runner/tool-result-context-guard.ts)
  • Dallin Romney: Recent merged work refactored the embedded attempt runner helper surface that this PR must now target after rebasing to current main. (role: recent adjacent contributor; confidence: medium; commits: d165100c936a; files: src/agents/embedded-agent-runner/run/attempt.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 12, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 12, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label May 27, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 27, 2026
@clawsweeper

clawsweeper Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg: ✨ hatched 🌱 uncommon Brave Diff Drake. Rarity: 🌱 uncommon. Trait: purrs at green checks.

Details

Share on X: post this hatch
Copy: My PR egg hatched a 🌱 uncommon Brave Diff Drake in ClawSweeper.
Hatchability:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

About:

  • Eggs appear after real-behavior proof passes. They are collectible flavor only.
  • Review momentum changes the shell state: follow-up work warms it, re-review makes it wobble, and a clean final review lets it hatch.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant