Keep onboarding agent timer heartbeats disabled (#23552)

## Thinking Path

> - Paperclip manages agents and their work.
> - Onboarding hires the first agent in a company.
> - Normal new-agent settings disable timer heartbeats.
> - The onboarding hire path overrides that setting and enables a
five-minute timer.
> - This change makes onboarding use the normal settings and preserves
saved policy when reconnecting an existing agent.
> - New hires keep on-demand wakes without an unwanted timer.

## Linked Issues or Issue Description

**What happened?**

Completing first-agent onboarding sends `heartbeat.enabled: true` with a
300-second interval. This differs from other new-agent paths. The
enabled timer can prevent idle sleep even when the selected runtime does
not execute unscoped timer heartbeats.

**Expected behavior**

First-agent onboarding must use the normal disabled timer default.
On-demand wakes must stay enabled. Reconnecting an existing agent must
preserve its saved policy.

**Steps to reproduce**

1. Create a company and complete first-agent onboarding.
2. Inspect the hire request's runtime configuration.
3. Before this change, its timer is enabled. After this change, it is
disabled.

## What Changed

- Use the normal new-agent runtime configuration for onboarding drafts
and hires.
- Keep the existing agent's runtime policy when reconnecting it.
- Test new hires, restored drafts, existing policy, and on-demand wakes.
- Document the default. The large wizard only changes its helper and
call sites; the merge logic and tests stay in the small runtime-config
module.

## Verification

- `pnpm exec vitest run ui/src/lib/new-agent-runtime-config.test.ts
ui/src/lib/onboarding-state.test.ts`: 10 tests passed.
- `pnpm --filter @paperclipai/ui typecheck`: passed.
- `pnpm verify`: selected 2,317 test files. An unrelated CPU timing
assertion failed in `server/src/event-loop-stall-monitor.test.ts`; the
broad run was then stopped (exit 130). This is not a passing full-suite
claim. Required CI must pass for the final head.
- [Full CI
run](https://github.com/paperclipai/paperclip/actions/runs/46974544702)
is green on final head `913daa0d0ff`, including the rerun of jobs
interrupted by runner shutdown. Greptile is 5/5 on that same head, with
no unresolved comments or merge conflicts.
- `git diff --check`: passed. Reviewed and scanned the diff for secrets,
private URLs, personal data, and infrastructure identifiers.

## Risks

Low risk. New hires now match the established new-agent default.
Existing agent settings stay intact during reconnection. No database
schema or scheduler changes. Existing records require a separate, scoped
data repair.

## Model Used

OpenAI Codex, `gpt-6.1-sol`, xhigh reasoning effort, with local code and
test tools.

## Checklist

- [x] Included project context and the problem
- [x] Specified the model used
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] Described the bug with the issue-template labels
- [x] Kept internal issue links and operational identifiers out of this
public PR
- [x] Used a descriptive branch name
- [x] Focused tests and UI typecheck pass; the interrupted broad run is
disclosed above
- [x] Added regression coverage and updated documentation
- [x] Documented risks
- [x] All required CI gates are green
- [x] Greptile is 5/5 with no unresolved comments
- [x] Will address review findings before requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Devin FoleyandPaperclip authored and GitHub committed 2026-12-02 13:41:34 -08:00
1 parent 3d0e0b6dd9
commit 34389a7921
4 files changed
+51 -8

No files matched your search

+4
View File
@@ -54,6 +54,10 @@ start execution. This preference does not change the org chart or permissions.
### Agent Execution
New agents, including the first agent hired during onboarding, default to no
timer heartbeat. On-demand wakes remain enabled. Reconnecting an existing agent
through onboarding preserves its saved heartbeat policy.
Agents have an **Advanced** tab for editing their settings across all configuration tabs
as a versioned YAML document. Instructions, skills, tools, channels, trust,
secret operations, API keys, and revision restore use their existing domain APIs.
+10 -7
View File
@@ -169,7 +169,7 @@ import { buildFixedClaudeOAuthBinding, CLAUDE_OAUTH_TOKEN_ENV_KEY } from "./envi
import { defaultCreateValues } from "./agent-config-defaults";
import { onboardingDraftStorage, restoreOnboardingState } from "../lib/onboarding-state";
import { selectDefaultCompanyGoalId } from "../lib/onboarding-launch";
import { buildNewAgentRuntimeConfig } from "../lib/new-agent-runtime-config";
import { buildNewAgentRuntimeConfig, buildOnboardingAgentRuntimeConfig } from "../lib/new-agent-runtime-config";
import { DEFAULT_CODEX_LOCAL_BYPASS_APPROVALS_AND_SANDBOX } from "@paperclipai/adapter-codex-local";
import { DEFAULT_CURSOR_LOCAL_MODEL } from "@paperclipai/adapter-cursor-local";
import { DEFAULT_GEMINI_LOCAL_MODEL } from "@paperclipai/adapter-gemini-local";
@@ -2556,11 +2556,14 @@ function OnboardingWizardInner({
return config;
}
function buildSetupRuntimeConfig(heartbeatEnabled: boolean, existingAgent?: Agent) {
function buildSetupRuntimeConfig(existingAgent?: Agent) {
const savedAgent = existingAgent ?? restoredSetup;
const { aiConnection: _savedBinding, ...runtimeConfig } = savedAgent?.companyId === createdCompanyId ? savedAgent.runtimeConfig : {};
const runtimeConfig = buildOnboardingAgentRuntimeConfig(
savedAgent?.companyId === createdCompanyId ? savedAgent.runtimeConfig : {},
{ preserveExisting: Boolean(existingAgent) },
);
const binding = managedBindingForStep();
return { ...runtimeConfig, ...(!existingAgent ? buildNewAgentRuntimeConfig({ heartbeatEnabled }) : {}), ...(binding ? { aiConnection: binding } : {}) };
return { ...runtimeConfig, ...(binding ? { aiConnection: binding } : {}) };
}
const setupSnapshot = (step === 3 || step === 4) && setupPrepared && setupAgentId && !createdAgentId && !loading
@@ -2568,7 +2571,7 @@ function OnboardingWizardInner({
...(sourceSelected && runnerDiscoveryReady ? {
adapterType, runner,
adapterConfig: buildAdapterConfig(Boolean(apiKeySecretRef.current?.binding)),
defaultEnvironmentId: resolvedLoginEnvironmentId, runtimeConfig: buildSetupRuntimeConfig(false),
defaultEnvironmentId: resolvedLoginEnvironmentId, runtimeConfig: buildSetupRuntimeConfig(),
metadata: { ...restoredSetup?.metadata, setupAdapterPending: false },
} : {}),
})
@@ -2996,7 +2999,7 @@ function OnboardingWizardInner({
adapterType,
adapterConfig: hireAdapterConfig,
...(["codex_local", "claude_local", "opencode_local", "pi_local"].includes(adapterType) && (runner !== "auto" || existingRunner) ? { runner: existingRunner ?? runner } : {}),
runtimeConfig: buildSetupRuntimeConfig(true, existingAgent),
runtimeConfig: buildSetupRuntimeConfig(existingAgent),
}, createdCompanyId);
if (!isCurrent()) return;
rememberConnectedSelection(createdAgentId);
@@ -3054,7 +3057,7 @@ function OnboardingWizardInner({
// The wizard no longer composes or overwrites it.
onboardingFirstAgent: true,
...(restoredSetup?.companyId === createdCompanyId && restoredSetup.defaultEnvironmentId ? { defaultEnvironmentId: resolvedLoginEnvironmentId } : {}),
runtimeConfig: buildSetupRuntimeConfig(true)
runtimeConfig: buildSetupRuntimeConfig()
});
if (!isCurrent()) return;
if (hire.approval) {
+26 -1
View File
@@ -1,7 +1,7 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
import { AGENT_DEFAULT_MAX_CONCURRENT_RUNS } from "@paperclipai/shared";
import { buildNewAgentRuntimeConfig } from "./new-agent-runtime-config";
import { buildNewAgentRuntimeConfig, buildOnboardingAgentRuntimeConfig } from "./new-agent-runtime-config";
describe("buildNewAgentRuntimeConfig", () => {
it("defaults new agents to no timer heartbeat", () => {
@@ -35,3 +35,28 @@ describe("buildNewAgentRuntimeConfig", () => {
});
});
});
describe("buildOnboardingAgentRuntimeConfig", () => {
it("hires without a timer while retaining on-demand wakes", () => {
expect(buildOnboardingAgentRuntimeConfig()).toMatchObject({
heartbeat: { enabled: false, wakeOnDemand: true },
});
});
it("resets a restored setup's timer before completing the hire", () => {
const saved = {
heartbeat: { enabled: true, intervalSec: 300, wakeOnDemand: false },
aiConnection: { mode: "fixed", connectionId: "previous-selection" },
customSetting: "keep",
};
const result = buildOnboardingAgentRuntimeConfig(saved);
expect(result).toMatchObject({ heartbeat: { enabled: false, wakeOnDemand: true }, customSetting: "keep" });
expect(result).not.toHaveProperty("aiConnection");
expect(saved.heartbeat.enabled).toBe(true);
});
it("preserves an existing agent's explicit policy when reconnecting", () => {
const heartbeat = { enabled: true, intervalSec: 3600, wakeOnDemand: false };
expect(buildOnboardingAgentRuntimeConfig({ heartbeat }, { preserveExisting: true })).toEqual({ heartbeat });
});
});
+11
View File
@@ -18,3 +18,14 @@ export function buildNewAgentRuntimeConfig(input?: {
return config;
}
export function buildOnboardingAgentRuntimeConfig(
savedRuntimeConfig: Record<string, unknown> = {},
options?: { preserveExisting?: boolean },
): Record<string, unknown> {
const { aiConnection: _savedBinding, ...runtimeConfig } = savedRuntimeConfig;
return {
...runtimeConfig,
...(!options?.preserveExisting ? buildNewAgentRuntimeConfig() : {}),
};
}