Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(onboarding): gate discovery progress by phase (#14842)

Innei3864a1eaab5e
diff --git a/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/utils.ts b/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/utils.ts
index 3d0a3744fce..86c0369bcde 100644
--- a/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/utils.ts
+++ b/packages/builtin-tool-web-onboarding/src/ExecutionRuntime/utils.ts
@@ -57,7 +57,11 @@ export const formatWebOnboardingStateMessage = (state: OnboardingStateContext) =
'Questioning rule: prefer the `lobe-user-interaction____askUserQuestion` tool call for structured collection or explicit UI input. For natural exploratory questions, plain text is allowed.',
];
- if (state.remainingDiscoveryExchanges !== undefined && state.remainingDiscoveryExchanges > 0) {
+ if (
+ state.phase === 'discovery' &&
+ state.remainingDiscoveryExchanges !== undefined &&
+ state.remainingDiscoveryExchanges > 0
+ ) {
const currentDiscoveryExchanges = state.discoveryUserMessageCount ?? 0;
const recommendedTarget = currentDiscoveryExchanges + state.remainingDiscoveryExchanges;
@@ -68,6 +72,7 @@ export const formatWebOnboardingStateMessage = (state: OnboardingStateContext) =
`Recommended: ${state.remainingDiscoveryExchanges} more user exchange(s) before moving to summary. Do not rush — keep exploring different aspects of the user's work and life.`,
);
} else if (
+ state.phase === 'discovery' &&
state.discoveryUserMessageCount !== undefined &&
state.remainingDiscoveryExchanges === 0
) {
diff --git a/src/utils/webOnboardingToolResult.test.ts b/src/utils/webOnboardingToolResult.test.ts
index f795d2abc4a..1f0cbadca68 100644
--- a/src/utils/webOnboardingToolResult.test.ts
+++ b/src/utils/webOnboardingToolResult.test.ts
@@ -53,12 +53,12 @@ describe('web onboarding tool result helpers', () => {
expect(message).toContain('Phase: Discovery');
});
- it('formats target-reached discovery progress when remaining discovery exchanges is 0', () => {
+ it('formats target-reached discovery progress only during discovery phase', () => {
const message = formatWebOnboardingStateMessage({
discoveryUserMessageCount: 4,
finished: false,
missingStructuredFields: [],
- phase: 'summary',
+ phase: 'discovery',
remainingDiscoveryExchanges: 0,
topicId: 'topic-1',
version: 1,
@@ -69,4 +69,19 @@ describe('web onboarding tool result helpers', () => {
'Discovery progress: recommended target reached after 4 user exchange(s).',
);
});
+
+ it('does not include discovery progress during summary phase', () => {
+ const message = formatWebOnboardingStateMessage({
+ discoveryUserMessageCount: 4,
+ finished: false,
+ missingStructuredFields: [],
+ phase: 'summary',
+ remainingDiscoveryExchanges: 0,
+ topicId: 'topic-1',
+ version: 1,
+ });
+
+ expect(message).toContain('Phase: Summary');
+ expect(message).not.toContain('Discovery progress:');
+ });
});