feat(config): support per-agent compaction overrides#69988
Conversation
Greptile SummaryThis PR adds optional per-agent compaction overrides ( Confidence Score: 4/5Not ready to merge — the missing Two P1 issues share the same root cause (missing fallback in
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/pi-settings.ts
Line: 44-49
Comment:
**Missing fallback to defaults when agent has no list entry**
When `agentId` is provided but no matching entry exists in `agents.list`, `resolveAgentConfig` returns `undefined`, so `?.compaction` resolves to `undefined` — silently dropping `agents.defaults.compaction` for any agent that runs without an explicit list entry. The parallel helper `resolveAgentContextLimits` shows the correct pattern with a `?? defaults` guard.
```suggestion
function resolveCompactionConfig(params: { cfg?: OpenClawConfig; agentId?: string }) {
if (params.cfg && params.agentId) {
return (
resolveAgentConfig(params.cfg, params.agentId)?.compaction ??
params.cfg?.agents?.defaults?.compaction
);
}
return params.cfg?.agents?.defaults?.compaction;
}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/agents/pi-embedded-runner/extensions.ts
Line: 92-95
Comment:
**Same missing fallback as `resolveCompactionConfig`**
If `agentId` is set but doesn't match any entry in `agents.list`, `resolveAgentConfig` returns `undefined` and `?.compaction` yields `undefined`, discarding the defaults compaction config. This is the same class of regression as in `pi-settings.ts`.
```suggestion
const compactionCfg =
params.cfg && params.agentId
? (resolveAgentConfig(params.cfg, params.agentId)?.compaction ??
params.cfg?.agents?.defaults?.compaction)
: params.cfg?.agents?.defaults?.compaction;
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/config/zod-schema.agent-compaction.ts
Line: 27-28
Comment:
**`modelFallbacks` silently added to defaults compaction schema**
The old inline schema in `zod-schema.agent-defaults.ts` did not include `modelFallbacks`. Extracting it into the shared `AgentCompactionSchema` introduces the field into `agents.defaults.compaction` as an accepted (but previously unknown) key, as confirmed by the generated schema diff. If this is intentional, a note in the PR or a type-level comment would clarify the intended surface; if not, `modelFallbacks` should be omitted from the shared schema or the defaults schema should exclude it explicitly.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: .github/workflows/ci-check-testbox.yml
Line: 24-25
Comment:
**Large CI resource bump with no explanation**
The runner jumps from `blacksmith-8vcpu` to `blacksmith-32vcpu` (4× CPU) and the timeout from 5 to 30 minutes (6×). The PR description doesn't mention this change. Is this intentional (e.g., to cover a newly-expanded test suite), or was it left over from local debugging? The testbox workflow is only triggered on `workflow_dispatch` or `.github/workflows/**` path changes, so the blast radius is limited — but an unintended 4× resource tier in a shared CI config is worth verifying explicitly.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "feat(config): support per-agent compacti..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 230a78ea14
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟡 Crash/DoS via unsafe object spread of optional compaction sub-objects in resolveAgentConfig
Description
Impact: a malformed or partial agent configuration (e.g., defaults include RecommendationAvoid spreading possibly Example fix: const qualityGuardDefaults =
agentDefaults?.compaction?.qualityGuard && typeof agentDefaults.compaction.qualityGuard === "object"
? agentDefaults.compaction.qualityGuard
: undefined;
const qualityGuardEntry =
entry.compaction.qualityGuard && typeof entry.compaction.qualityGuard === "object"
? entry.compaction.qualityGuard
: undefined;
qualityGuard: qualityGuardDefaults || qualityGuardEntry
? { ...(qualityGuardDefaults ?? {}), ...(qualityGuardEntry ?? {}) }
: undefined,
const memoryFlushDefaults =
agentDefaults?.compaction?.memoryFlush && typeof agentDefaults.compaction.memoryFlush === "object"
? agentDefaults.compaction.memoryFlush
: undefined;
const memoryFlushEntry =
entry.compaction.memoryFlush && typeof entry.compaction.memoryFlush === "object"
? entry.compaction.memoryFlush
: undefined;
memoryFlush: memoryFlushDefaults || memoryFlushEntry
? { ...(memoryFlushDefaults ?? {}), ...(memoryFlushEntry ?? {}) }
: undefined,Also consider rejecting Analyzed PR: #69988 at commit Last updated on: 2026-04-22T05:57:25Z |
|
Addressed the review feedback in commit Resolved items:
Verification after the patch:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e811e619a8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Direct follow-up for the two latest review threads:
Re-ran the changed-file verification after these fixes; it passed again (typecheck, lint, import-cycle guard, and agents tests). |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 63f5cbca58
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Hi @scottgl9 — I'm the original reporter of #57174 (the per-agent compaction request) and previously had #60807 attempting the same feature. clawsweeper correctly closed #60807 as superseded by this PR — yours is a cleaner, more focused implementation. Sharing some production context that may help validation: Use case that motivated #57174: mixed-tier agent hierarchy with Opus 4.6 (1M context) and GLM-5 (200k context) running side by side. With shared
Test scenarios worth covering:
Happy to test against our 17-agent production setup once this lands. Let me know if you want me to dry-run the merged config logic against any specific edge cases. |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: this branch is now an outdated, conflicting partial implementation, while the active replacement PR owns the same broader per-agent compaction work with proof and focused remaining review. Canonical path: Close this branch and converge the remaining per-agent compaction contract through #83637 and the canonical issue it closes. So I’m closing this here and keeping the remaining discussion on #83637 and #52732. Review detailsBest possible solution: Close this branch and converge the remaining per-agent compaction contract through #83637 and the canonical issue it closes. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main rejects Is this the best way to solve the issue? No. The feature direction is valid, but this branch is no longer the best merge vehicle because the active replacement PR owns the broader contract and proof path. Security review: Security review cleared: No concrete security or supply-chain issue was found in the final PR surface; the concerns are functional config compatibility and runtime scope. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 29f8715f05c8. |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
agents.defaults.compaction, so all agents had to share the same compaction instructions and runtime settings.agents.list[].compactionsupport, merged it over defaults, and threaded effective per-agent compaction config through embedded runtime compaction paths.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
agents.defaults.compaction.Regression Test Plan (if applicable)
src/agents/agent-scope.test.tssrc/agents/pi-settings.test.tssrc/agents/pi-embedded-runner/extensions.test.tscustomInstructionswins over defaultcustomInstructionsUser-visible / Behavior Changes
agents.list[].compactionentries.agents.defaults.compactionand override defaults when set.agents.list[].compaction.customInstructionsnow lets each agent provide its own compaction guidance.Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation:Repro + Verification
Environment
agents.defaults.compactionplusagents.list[].compactionSteps
agents.defaults.compaction.customInstructions.agents.list[].compaction.customInstructionsfor a specific agent.Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
Review Conversations
Compatibility / Migration
Risks and Mitigations
agentIdthrough the affected embedded runtime setup paths and adds tests around the effective runtime behavior.