From 34389a7921a684e5e9ede341ed95dfef5a52fca7 Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Wed, 2 Dec 2026 13:41:34 -0800 Subject: [PATCH] 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 --- doc/PRODUCT.md | 4 +++ ui/src/components/OnboardingWizard.tsx | 17 +++++++------ ui/src/lib/new-agent-runtime-config.test.ts | 27 ++++++++++++++++++++- ui/src/lib/new-agent-runtime-config.ts | 11 +++++++++ 4 files changed, 51 insertions(+), 8 deletions(-) diff --git a/doc/PRODUCT.md b/doc/PRODUCT.md index 029165224ca..f0bdce50a5e 100644 --- a/doc/PRODUCT.md +++ b/doc/PRODUCT.md @@ -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. diff --git a/ui/src/components/OnboardingWizard.tsx b/ui/src/components/OnboardingWizard.tsx index 959731d492f..7736278e25f 100644 --- a/ui/src/components/OnboardingWizard.tsx +++ b/ui/src/components/OnboardingWizard.tsx @@ -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) { diff --git a/ui/src/lib/new-agent-runtime-config.test.ts b/ui/src/lib/new-agent-runtime-config.test.ts index 5d60a4ca7dd..f7def696811 100644 --- a/ui/src/lib/new-agent-runtime-config.test.ts +++ b/ui/src/lib/new-agent-runtime-config.test.ts @@ -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 }); + }); +}); diff --git a/ui/src/lib/new-agent-runtime-config.ts b/ui/src/lib/new-agent-runtime-config.ts index 478321ce9e9..93bee633c38 100644 --- a/ui/src/lib/new-agent-runtime-config.ts +++ b/ui/src/lib/new-agent-runtime-config.ts @@ -18,3 +18,14 @@ export function buildNewAgentRuntimeConfig(input?: { return config; } + +export function buildOnboardingAgentRuntimeConfig( + savedRuntimeConfig: Record = {}, + options?: { preserveExisting?: boolean }, +): Record { + const { aiConnection: _savedBinding, ...runtimeConfig } = savedRuntimeConfig; + return { + ...runtimeConfig, + ...(!options?.preserveExisting ? buildNewAgentRuntimeConfig() : {}), + }; +}