Skip to content

Commit a7fe755

Browse files
authored
fix: Don't stop analytics after integration run inside self-driving (#771)
1 parent 3049d9c commit a7fe755

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

src/lib/agent/runner/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export { shouldDisableAsk } from './shared/bootstrap';
4545
export async function runAgent(
4646
programConfig: ProgramConfig,
4747
session: WizardSession,
48+
options: { composed?: boolean } = {},
4849
): Promise<void> {
4950
if (!programConfig.run) {
5051
throw new Error(`Program "${programConfig.id}" has no run configuration.`);
@@ -55,7 +56,7 @@ export async function runAgent(
5556
? await programConfig.run(session)
5657
: programConfig.run;
5758

58-
await runProgram(session, runDef, programConfig);
59+
await runProgram(session, runDef, programConfig, options);
5960
}
6061

6162
/**
@@ -69,6 +70,7 @@ export async function runProgram(
6970
session: WizardSession,
7071
config: ProgramRun,
7172
programConfig: ProgramConfig,
73+
options: { composed?: boolean } = {},
7274
): Promise<void> {
7375
const boot = await bootstrapProgram(session, config, programConfig);
7476

@@ -85,11 +87,18 @@ export async function runProgram(
8587
if (isOrchestratorEnabled(boot.wizardFlags)) {
8688
getUI().log.info('Task-queue orchestrator enabled.');
8789
stampVariant(boot, WizardVariant.ORCHESTRATOR);
90+
// composed-run guard is linear-only; the orchestrator is experimental.
8891
return await runOrchestrator(session, programConfig, boot);
8992
}
9093

9194
stampVariant(boot, WizardVariant.BASE);
92-
return await runLinearProgram(session, config, programConfig, boot);
95+
return await runLinearProgram(
96+
session,
97+
config,
98+
programConfig,
99+
boot,
100+
options.composed ?? false,
101+
);
93102
} finally {
94103
flushScanReport(session);
95104
}

src/lib/agent/runner/linear.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export async function runLinearProgram(
4343
config: ProgramRun,
4444
programConfig: ProgramConfig,
4545
boot: BootstrapResult,
46+
composed = false,
4647
): Promise<void> {
4748
const {
4849
skillsBaseUrl,
@@ -274,6 +275,10 @@ export async function runLinearProgram(
274275
});
275276
}
276277

278+
// A composed sub-run (integration inside self-driving) skips the terminal
279+
// outro + analytics shutdown so the shared client survives the host's run.
280+
if (composed) return;
281+
277282
// 11. Outro
278283
// Push outro data through the UI (not via direct `session.outroData = ...`
279284
// mutation) so the live store gets the value. agent-runner's `session`

src/lib/programs/posthog-integration/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,10 @@ export const integrationRunStep: ProgramStep = {
289289
id: 'run',
290290
label: 'Integration',
291291
screenId: 'run',
292-
run: (session) => runAgent(posthogIntegrationConfig, session),
292+
// composed: runs inside the host program (self-driving), so skip the
293+
// integration's terminal outro + analytics shutdown of the shared client.
294+
run: (session) =>
295+
runAgent(posthogIntegrationConfig, session, { composed: true }),
293296
isComplete: (session) =>
294297
session.runPhase === RunPhase.Completed ||
295298
session.runPhase === RunPhase.Error,

0 commit comments

Comments
 (0)