fix(heartbeat): extract ISSUE_ASSIGNED_WAKE_REASON constant + pass policy to evaluateSessionCompaction

- Export ISSUE_ASSIGNED_WAKE_REASON near other wake reason constants; use it in
  decideSessionCompactionTrigger instead of a bare string literal (greptile P2).
- Add optional policy param to evaluateSessionCompaction; use pre-parsed policy
  from caller to avoid double parseSessionCompactionPolicy call (greptile P2).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Engineer 2026-07-04 21:49:08 +02:00 committed by Paperclip Engineer
parent cb6294ec02
commit 08e2c3b2eb
1 changed files with 4 additions and 2 deletions

View File

@ -821,6 +821,7 @@ const GIT_SENSITIVE_LOCAL_ADAPTER_TYPES = new Set([
]); ]);
export { MAX_TURN_CONTINUATION_RETRY_REASON }; export { MAX_TURN_CONTINUATION_RETRY_REASON };
export const MAX_TURN_CONTINUATION_WAKE_REASON = "max_turns_continuation_retry"; export const MAX_TURN_CONTINUATION_WAKE_REASON = "max_turns_continuation_retry";
export const ISSUE_ASSIGNED_WAKE_REASON = "issue_assigned";
const MAX_TURN_CONTINUATION_DEFAULT_MAX_ATTEMPTS = 2; const MAX_TURN_CONTINUATION_DEFAULT_MAX_ATTEMPTS = 2;
const MAX_TURN_CONTINUATION_MAX_ATTEMPTS_CAP = 10; const MAX_TURN_CONTINUATION_MAX_ATTEMPTS_CAP = 10;
const MAX_TURN_CONTINUATION_DEFAULT_DELAY_MS = 1_000; const MAX_TURN_CONTINUATION_DEFAULT_DELAY_MS = 1_000;
@ -3590,7 +3591,7 @@ export function decideSessionCompactionTrigger(
) { ) {
return { reason: "no open issues for agent", triggeredBy: "t3" }; return { reason: "no open issues for agent", triggeredBy: "t3" };
} }
if (policy.rotateOnNewIssueWake && wakeReason === "issue_assigned") { if (policy.rotateOnNewIssueWake && wakeReason === ISSUE_ASSIGNED_WAKE_REASON) {
return { reason: "wake triggered by new issue assignment", triggeredBy: "t4" }; return { reason: "wake triggered by new issue assignment", triggeredBy: "t4" };
} }
return null; return null;
@ -11613,6 +11614,7 @@ export function heartbeatService(
continuationSummaryBody?: string | null; continuationSummaryBody?: string | null;
wakeReason?: string | null; wakeReason?: string | null;
openIssuesCount?: number | null; openIssuesCount?: number | null;
policy?: SessionCompactionPolicy;
}): Promise<SessionCompactionDecision> { }): Promise<SessionCompactionDecision> {
const { agent, sessionId, issueId } = input; const { agent, sessionId, issueId } = input;
if (!sessionId) { if (!sessionId) {
@ -11625,7 +11627,7 @@ export function heartbeatService(
}; };
} }
const policy = parseSessionCompactionPolicy(agent); const policy = input.policy ?? parseSessionCompactionPolicy(agent);
if (!policy.enabled || !hasSessionCompactionThresholds(policy)) { if (!policy.enabled || !hasSessionCompactionThresholds(policy)) {
return { return {
rotate: false, rotate: false,