Skip to content

feat(openclaw): support ratio-based commit threshold#1418

Open
yeyitech wants to merge 1 commit intovolcengine:mainfrom
yeyitech:feat/openclaw-commit-threshold-ratio
Open

feat(openclaw): support ratio-based commit threshold#1418
yeyitech wants to merge 1 commit intovolcengine:mainfrom
yeyitech:feat/openclaw-commit-threshold-ratio

Conversation

@yeyitech
Copy link
Copy Markdown
Contributor

@yeyitech yeyitech commented Apr 13, 2026

Summary

  • add commitTokenThresholdRatio to the OpenClaw plugin config and manifest
  • derive the effective auto-commit threshold from runtime model context window or token budget when ratio is set
  • keep fixed commitTokenThreshold as the fallback and document/test the precedence

Testing

  • npm test -- tests/ut/config.test.ts tests/ut/context-engine-afterTurn.test.ts
  • npm test

Closes #1172

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

1172 - Fully compliant

Compliant requirements:

  • Added commitTokenThresholdRatio to config and manifest
  • Implemented ratio-based threshold calculation
  • Ratio takes precedence over fixed threshold
  • Ratio clamped to max 0.49 (49%)
  • Extracts context window from runtimeContext (multiple keys/nested paths)
  • Falls back to fixed threshold when ratio is set but no context window/token budget available
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🏅 Score: 92
🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Indentation Syntax Error

The new diagnostic fields in afterTurn_skip and afterTurn_commit have inconsistent indentation, which will cause a JavaScript/TypeScript syntax error.

commitTokenThreshold: commitThreshold.value,
commitTokenThresholdSource: commitThreshold.source,
commitTokenThresholdRatio: commitThreshold.ratio ?? null,
commitTokenThresholdBasis: commitThreshold.basis ?? null,
Indentation Syntax Error

The new diagnostic fields in afterTurn_commit have inconsistent indentation, which will cause a JavaScript/TypeScript syntax error.

commitTokenThreshold: commitThreshold.value,
commitTokenThresholdSource: commitThreshold.source,
commitTokenThresholdRatio: commitThreshold.ratio ?? null,
commitTokenThresholdBasis: commitThreshold.basis ?? null,

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[Feature]: commitTokenThreshold 应基于模型上下文窗口百分比,而非固定值

1 participant