Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🦉 fix: Quiet Idle Subagent Discovery While Preserving Child Wakeups (#16308)
lia-by-librechat[bot]04e637e6758b
diff --git a/client/src/components/Chat/Presentation.test.tsx b/client/src/components/Chat/Presentation.test.tsxindex b539ea6026..2d171b6202 100644--- a/client/src/components/Chat/Presentation.test.tsx+++ b/client/src/components/Chat/Presentation.test.tsx@@ -14,10 +14,13 @@ const mockOpenArtifactLabel = 'Open Artifact';const mockChildPanelLabel = 'Child activity panel loaded';const mockOpenChildLabel = 'Open Child Activity';const mockSelectAgentConversationLabel = 'Select Agent Conversation';-const mockUseParentSubagentsQuery = jest.fn((_conversationId?: string, _config?: unknown) => ({- data: undefined,- refetch: jest.fn(),-}));+const mockStartAgentRunLabel = 'Start Agent Run';+const mockUseParentSubagentsQuery = jest.fn(+ (_conversationId?: string, _config?: unknown, _isSubmitting?: boolean) => ({+ data: undefined,+ refetch: jest.fn(),+ }),+);jest.mock('~/components/Artifacts/Artifacts', () => {const artifactPanelLabel = 'Artifact panel loaded';@@ -63,8 +66,8 @@ jest.mock('~/hooks/Artifacts/useResetArtifactsOnConversationChange', () => ({jest.mock('~/data-provider', () => ({useDeleteFilesMutation: () => ({ mutateAsync: jest.fn() }),- useParentSubagentsQuery: (conversationId: string, config?: unknown) =>- mockUseParentSubagentsQuery(conversationId, config),+ useParentSubagentsQuery: (conversationId: string, config?: unknown, isSubmitting?: boolean) =>+ mockUseParentSubagentsQuery(conversationId, config, isSubmitting),}));jest.mock('~/hooks', () => ({@@ -141,6 +144,15 @@ const SelectAgentConversation = () => {);};+const StartAgentRun = () => {+ const setSubmitting = useSetRecoilState(store.isSubmittingFamily(0));+ return (+ <button type="button" onClick={() => setSubmitting(true)}>+ {mockStartAgentRunLabel}+ </button>+ );+};+describe('Presentation Artifact loading', () => {it('loads the Artifact panel bundle only when the panel is opened', async () => {const testGlobal = globalThis as typeof globalThis & {@@ -163,7 +175,7 @@ describe('Presentation Artifact loading', () => {expect(await screen.findByText(mockArtifactPanelLabel)).toBeInTheDocument();expect(testGlobal.presentationArtifactModuleEvaluations).toBe(1);- expect(mockUseParentSubagentsQuery).toHaveBeenCalledWith('', { enabled: false });+ expect(mockUseParentSubagentsQuery).toHaveBeenCalledWith('', { enabled: false }, false);});it('loads the parent child index only for Agent conversations', () => {@@ -172,16 +184,25 @@ describe('Presentation Artifact loading', () => {<RecoilRoot><Presentation><SelectAgentConversation />+ <StartAgentRun /></Presentation></RecoilRoot></ChatSurfaceHarness>,);- expect(mockUseParentSubagentsQuery).toHaveBeenLastCalledWith('', { enabled: false });+ expect(mockUseParentSubagentsQuery).toHaveBeenLastCalledWith('', { enabled: false }, false);fireEvent.click(screen.getByRole('button', { name: mockSelectAgentConversationLabel }));- expect(mockUseParentSubagentsQuery).toHaveBeenLastCalledWith('agent-conversation', {- enabled: true,- });+ expect(mockUseParentSubagentsQuery).toHaveBeenLastCalledWith(+ 'agent-conversation',+ { enabled: true },+ false,+ );+ fireEvent.click(screen.getByRole('button', { name: mockStartAgentRunLabel }));+ expect(mockUseParentSubagentsQuery).toHaveBeenLastCalledWith(+ 'agent-conversation',+ { enabled: true },+ true,+ );});it('uses one panel slot and lets an opened artifact replace child activity', async () => {diff --git a/client/src/components/Chat/Presentation.tsx b/client/src/components/Chat/Presentation.tsxindex 95a10655cc..46a176099f 100644--- a/client/src/components/Chat/Presentation.tsx+++ b/client/src/components/Chat/Presentation.tsx@@ -32,6 +32,7 @@ export default function Presentation({ children }: { children: React.ReactNode }const conversationId = useRecoilValue(store.conversationIdByIndex(0));const conversationEndpoint = useRecoilValue(store.effectiveEndpointByIndex(0));const conversationAgentId = useRecoilValue(store.conversationAgentIdByIndex(0));+ const isSubmitting = useRecoilValue(store.isSubmittingFamily(0));const selectedSubagent = useAtomValue(activeSubagentPanel);const setSelectedSubagent = useSetAtom(activeSubagentPanel);const resetSelectedSubagent = useCallback(() => setSelectedSubagent(null), [setSelectedSubagent]);@@ -145,6 +146,7 @@ export default function Presentation({ children }: { children: React.ReactNode }<ParentSubagentsProviderconversationId={conversationId ?? ''}enabled={conversationEndpoint === EModelEndpoint.agents && conversationAgentId != null}+ isSubmitting={isSubmitting}><SidePanelGroup panel={panelElement}><main className="flex h-full flex-col overflow-y-auto" role="main">diff --git a/client/src/components/Chat/Subagents/ParentSubagentsProvider.test.tsx b/client/src/components/Chat/Subagents/ParentSubagentsProvider.test.tsxindex 59eade9bda..d722f4e432 100644--- a/client/src/components/Chat/Subagents/ParentSubagentsProvider.test.tsx+++ b/client/src/components/Chat/Subagents/ParentSubagentsProvider.test.tsx@@ -58,9 +58,11 @@ describe('ParentSubagentsProvider', () => {</ParentSubagentsProvider>,);- expect(mockUseParentSubagentsQuery).toHaveBeenCalledWith('parent-conversation', {- enabled: true,- });+ expect(mockUseParentSubagentsQuery).toHaveBeenCalledWith(+ 'parent-conversation',+ { enabled: true },+ false,+ );expect(context?.byMessageId.get('parent-message')).toEqual([eventChild]);expect(context?.byThreadId.get('tool-thread')).toEqual(toolChild);let result: ParentSubagentIndex | undefined;@@ -70,4 +72,18 @@ describe('ParentSubagentsProvider', () => {expect(refetch).toHaveBeenCalledTimes(1);expect(result).toEqual(refreshed);});++ it('marks an active parent run for prompt discovery', () => {+ mockUseParentSubagentsQuery.mockReturnValue({ data: undefined, refetch: jest.fn() });+ render(+ <ParentSubagentsProvider conversationId="parent-conversation" enabled isSubmitting>+ <div />+ </ParentSubagentsProvider>,+ );+ expect(mockUseParentSubagentsQuery).toHaveBeenCalledWith(+ 'parent-conversation',+ { enabled: true },+ true,+ );+ });});diff --git a/client/src/components/Chat/Subagents/ParentSubagentsProvider.tsx b/client/src/components/Chat/Subagents/ParentSubagentsProvider.tsxindex 82ec322f94..d04c75f252 100644--- a/client/src/components/Chat/Subagents/ParentSubagentsProvider.tsx+++ b/client/src/components/Chat/Subagents/ParentSubagentsProvider.tsx@@ -21,13 +21,15 @@ const ParentSubagentsContext = createContext<ParentSubagentsContextValue>(defaulexport function ParentSubagentsProvider({conversationId,enabled,+ isSubmitting = false,children,}: {conversationId: string;enabled: boolean;+ isSubmitting?: boolean;children: React.ReactNode;}) {- const { data, refetch } = useParentSubagentsQuery(conversationId, { enabled });+ const { data, refetch } = useParentSubagentsQuery(conversationId, { enabled }, isSubmitting);const refresh = useCallback(async () => {const result = await refetch();return result.data;diff --git a/client/src/data-provider/Subagents/queries.polling.test.tsx b/client/src/data-provider/Subagents/queries.polling.test.tsxnew file mode 100644index 0000000000..13f49ae057--- /dev/null+++ b/client/src/data-provider/Subagents/queries.polling.test.tsx@@ -0,0 +1,120 @@+import React from 'react';+import { QueryKeys } from 'librechat-data-provider';+import { act, renderHook } from '@testing-library/react';+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';+import type { ParentSubagentIndex } from 'librechat-data-provider';+import { useParentSubagentsQuery } from './queries';++const mockGetParentSubagents = jest.fn();++jest.mock('librechat-data-provider', () => {+ const actual = jest.requireActual('librechat-data-provider');+ return {+ ...actual,+ dataService: {+ ...actual.dataService,+ getParentSubagents: (...args: unknown[]) => mockGetParentSubagents(...args),+ },+ };+});++const index: ParentSubagentIndex = {+ parentConversationId: 'parent',+ children: [],+ childrenTruncated: false,+};++function setup(isSubmitting = false) {+ const client = new QueryClient();+ const wrapper = ({ children }: { children: React.ReactNode }) => (+ <QueryClientProvider client={client}>{children}</QueryClientProvider>+ );+ const hook = renderHook(() => useParentSubagentsQuery('parent', undefined, isSubmitting), {+ wrapper,+ });+ return { ...hook, client };+}++describe('parent subagent discovery polling', () => {+ beforeEach(() => {+ jest.useFakeTimers();+ mockGetParentSubagents.mockReset();+ });++ afterEach(() => {+ jest.useRealTimers();+ });++ it('starts at the existing cadence and settles at one read per minute when empty', async () => {+ mockGetParentSubagents.mockResolvedValue(index);+ const { client, unmount } = setup();+ await act(async () => jest.advanceTimersByTimeAsync(0));+ expect(mockGetParentSubagents).toHaveBeenCalledTimes(1);+ await act(async () => jest.advanceTimersByTimeAsync(10_000));+ expect(mockGetParentSubagents).toHaveBeenCalledTimes(2);+ await act(async () => jest.advanceTimersByTimeAsync(59_000));+ expect(mockGetParentSubagents).toHaveBeenCalledTimes(2);+ await act(async () => jest.advanceTimersByTimeAsync(1_000));+ expect(mockGetParentSubagents).toHaveBeenCalledTimes(3);+ unmount();+ client.clear();+ });++ it('wakes immediately on child activity and resumes active-child refresh', async () => {+ mockGetParentSubagents+ .mockResolvedValueOnce(index)+ .mockResolvedValueOnce(index)+ .mockResolvedValue({ ...index, children: [{ status: 'running' }] });+ const { client, unmount } = setup();+ await act(async () => jest.advanceTimersByTimeAsync(10_000));+ expect(mockGetParentSubagents).toHaveBeenCalledTimes(2);++ await act(async () => {+ await client.invalidateQueries([QueryKeys.parentSubagents, 'parent']);+ });+ expect(mockGetParentSubagents).toHaveBeenCalledTimes(3);+ await act(async () => jest.advanceTimersByTimeAsync(2_000));+ expect(mockGetParentSubagents).toHaveBeenCalledTimes(4);+ unmount();+ client.clear();+ });++ it('does not retry or poll a missing parent on an idle tab', async () => {+ jest.spyOn(console, 'error').mockImplementation(() => undefined);+ mockGetParentSubagents.mockRejectedValue({ response: { status: 404 } });+ const { client, unmount } = setup();+ await act(async () => jest.advanceTimersByTimeAsync(0));+ await act(async () => jest.advanceTimersByTimeAsync(120_000));+ expect(mockGetParentSubagents).toHaveBeenCalledTimes(1);+ unmount();+ client.clear();+ });++ it('recovers when an initially missing parent persists during the first run', async () => {+ jest.spyOn(console, 'error').mockImplementation(() => undefined);+ mockGetParentSubagents.mockRejectedValueOnce({ response: { status: 404 } });+ mockGetParentSubagents.mockResolvedValue(index);+ const { client, unmount, result } = setup(true);+ await act(async () => jest.advanceTimersByTimeAsync(0));+ expect(mockGetParentSubagents).toHaveBeenCalledTimes(1);+ await act(async () => jest.advanceTimersByTimeAsync(10_000));+ await act(async () => jest.advanceTimersByTimeAsync(1));+ expect(mockGetParentSubagents).toHaveBeenCalledTimes(2);+ expect(result.current.data?.children).toEqual([]);+ unmount();+ client.clear();+ });++ it('retries a new parent during a running first turn but stops after readiness expires', async () => {+ jest.spyOn(console, 'error').mockImplementation(() => undefined);+ mockGetParentSubagents.mockRejectedValue({ response: { status: 404 } });+ const { client, unmount } = setup(true);+ await act(async () => jest.advanceTimersByTimeAsync(0));+ await act(async () => jest.advanceTimersByTimeAsync(10_000));+ expect(mockGetParentSubagents).toHaveBeenCalledTimes(2);+ await act(async () => jest.advanceTimersByTimeAsync(120_000));+ expect(mockGetParentSubagents).toHaveBeenCalledTimes(7);+ unmount();+ client.clear();+ });+});diff --git a/client/src/data-provider/Subagents/queries.test.ts b/client/src/data-provider/Subagents/queries.test.tsindex ddfc1ba556..9076a47161 100644--- a/client/src/data-provider/Subagents/queries.test.ts+++ b/client/src/data-provider/Subagents/queries.test.ts@@ -120,36 +120,60 @@ describe('subagent thread refresh policy', () => {expect(refetch).not.toHaveBeenCalled();});- it('refreshes active parent children quickly and discovers idle actors at a bounded cadence', () => {- expect(- parentSubagentsRefetchInterval({- parentConversationId: 'parent-conversation',- childrenTruncated: false,- children: [{ status: 'running' }],- } as ParentSubagentIndex),- ).toBe(2_000);- expect(- parentSubagentsRefetchInterval({+ it('retains fast live refresh but sparsifies quiet parent discovery', () => {+ const parent = (status?: ParentSubagentIndex['children'][number]['status']) =>+ ({parentConversationId: 'parent-conversation',childrenTruncated: false,- children: [{ status: 'dispatched' }],- } as ParentSubagentIndex),- ).toBe(10_000);+ children: status == null ? [] : [{ status }],+ }) as ParentSubagentIndex;++ expect(parentSubagentsRefetchInterval(parent('running'))).toBe(2_000);+ expect(parentSubagentsRefetchInterval(parent('dispatched'))).toBe(10_000);+ expect(parentSubagentsRefetchInterval(parent(), false, null, 1)).toBe(10_000);+ expect(parentSubagentsRefetchInterval(parent(), false, null, 2)).toBe(60_000);+ expect(parentSubagentsRefetchInterval(parent('completed'), false, null, 3)).toBe(60_000);+ expect(parentSubagentsRefetchInterval(parent(), true, null, 20)).toBe(10_000);expect(parentSubagentsRefetchInterval(undefined)).toBe(10_000);+ });++ it('stops idle 404 polling and gives a running first turn bounded readiness retries', () => {+ const missing = { response: { status: 404 } };+ expect(parentSubagentsRefetchInterval(undefined, false, missing, 0, Date.now() + 60_000)).toBe(+ false,+ );+ expect(parentSubagentsRefetchInterval(undefined, true, missing, 0, Date.now() + 60_000)).toBe(+ 10_000,+ );+ expect(parentSubagentsRefetchInterval(undefined, true, missing, 0, Date.now())).toBe(false);+ expect(parentSubagentsRefetchInterval(undefined, false, { response: { status: 503 } })).toBe(+ 60_000,+ );+ });+ it('keeps idle fallback and suppresses automatic 404 retries in the live query', () => {mockUseQuery.mockReturnValue({ data: undefined, error: null, refetch: jest.fn() });renderHook(() => useParentSubagentsQuery('parent-conversation'));expect(mockUseQuery.mock.calls.at(-1)?.[0]).toEqual(['parentSubagents', 'parent-conversation']);- expect(mockUseQuery.mock.calls.at(-1)?.[2]).toEqual(+ const options = mockUseQuery.mock.calls.at(-1)?.[2];+ expect(options).toEqual(expect.objectContaining({enabled: true,refetchOnWindowFocus: true,- refetchInterval: parentSubagentsRefetchInterval,refetchIntervalInBackground: false,staleTime: 5_000,}),);+ expect(options.retry(0, { response: { status: 404 } })).toBe(false);+ expect(options.retry(0, { response: { status: 500 } })).toBe(true);+ expect(options.retry(3, { response: { status: 500 } })).toBe(false);+ expect(+ options.refetchInterval(undefined, { state: { dataUpdateCount: 0, error: { status: 404 } } }),+ ).toBe(false);+ expect(+ options.refetchInterval({ children: [] }, { state: { dataUpdateCount: 2, error: null } }),+ ).toBe(60_000);});});diff --git a/client/src/data-provider/Subagents/queries.ts b/client/src/data-provider/Subagents/queries.tsindex 290b1e2f86..be9202727a 100644--- a/client/src/data-provider/Subagents/queries.ts+++ b/client/src/data-provider/Subagents/queries.ts@@ -10,20 +10,53 @@ import type {} from 'librechat-data-provider';import type { UseQueryOptions, QueryObserverResult } from '@tanstack/react-query';+const responseStatus = (error: unknown): number | undefined => {+ if (error == null || typeof error !== 'object') return undefined;+ const candidate = error as { status?: number; response?: { status?: number } };+ return candidate.response?.status ?? candidate.status;+};+export const ACTIVE_THREAD_REFRESH_MS = 2_000;const IDLE_PARENT_REFRESH_MS = 10_000;+const QUIET_PARENT_REFRESH_MS = 60_000;const CHILD_READY_POLL_WINDOW_MS = 60_000;-export const parentSubagentsRefetchInterval = (index: ParentSubagentIndex | undefined): number =>- index?.children.some((child) => child.status === 'running') === true- ? ACTIVE_THREAD_REFRESH_MS- : IDLE_PARENT_REFRESH_MS;+/** Streamed child lifecycle events wake local discovery; the capped fallback finds+ * children published elsewhere when this tab has no active parent stream. */+export const parentSubagentsRefetchInterval = (+ index: ParentSubagentIndex | undefined,+ isSubmitting = false,+ error?: unknown,+ dataUpdateCount = 0,+ readinessDeadline = 0,+): number | false => {+ if (responseStatus(error) === 404) {+ return isSubmitting && Date.now() < readinessDeadline ? IDLE_PARENT_REFRESH_MS : false;+ }+ if (index?.children.some((child) => child.status === 'running') === true) {+ return ACTIVE_THREAD_REFRESH_MS;+ }+ if (isSubmitting || index?.children.some((child) => child.status === 'dispatched')) {+ return IDLE_PARENT_REFRESH_MS;+ }+ if (index == null && error == null) {+ return IDLE_PARENT_REFRESH_MS;+ }+ // Recheck the first empty result soon: publication may still be committing.+ return dataUpdateCount <= 1 && error == null ? IDLE_PARENT_REFRESH_MS : QUIET_PARENT_REFRESH_MS;+};export const useParentSubagentsQuery = (parentConversationId: string,config?: UseQueryOptions<ParentSubagentIndex>,-) =>- useQuery<ParentSubagentIndex>(+ isSubmitting = false,+) => {+ const readinessKey = `${parentConversationId}\u0000${isSubmitting}`;+ const readiness = useMemo(+ () => ({ key: readinessKey, deadline: Date.now() + CHILD_READY_POLL_WINDOW_MS }),+ [readinessKey],+ );+ return useQuery<ParentSubagentIndex>([QueryKeys.parentSubagents, parentConversationId],() => dataService.getParentSubagents(parentConversationId),{@@ -33,11 +66,20 @@ export const useParentSubagentsQuery = (parentConversationId !== Constants.PENDING_CONVO,staleTime: 5_000,refetchOnWindowFocus: true,- refetchInterval: parentSubagentsRefetchInterval,+ retry: (failureCount, error) => responseStatus(error) !== 404 && failureCount < 3,+ refetchInterval: (index, query) =>+ parentSubagentsRefetchInterval(+ index,+ isSubmitting,+ query.state.error,+ query.state.dataUpdateCount,+ readiness.deadline,+ ),refetchIntervalInBackground: false,...config,},);+};const isTerminal = (status: SubagentThreadView['status']): boolean =>status === 'completed' ||@@ -80,12 +122,6 @@ export const subagentThreadRefetchInterval = (return isTerminal(view.status) ? false : ACTIVE_THREAD_REFRESH_MS;};-const responseStatus = (error: unknown): number | undefined => {- if (error == null || typeof error !== 'object') return undefined;- const candidate = error as { status?: number; response?: { status?: number } };- return candidate.response?.status ?? candidate.status;-};-export const isSubagentReadinessPending = (error: unknown,readinessDeadline: number,diff --git a/client/src/hooks/SSE/__tests__/useStepHandler.spec.ts b/client/src/hooks/SSE/__tests__/useStepHandler.spec.tsindex 7e0df6cdaf..4a712d1095 100644--- a/client/src/hooks/SSE/__tests__/useStepHandler.spec.ts+++ b/client/src/hooks/SSE/__tests__/useStepHandler.spec.ts@@ -3240,6 +3240,47 @@ describe('useStepHandler', () => {...overrides,});+ it('signals parent-index discovery on child lifecycle events, not every progress delta', () => {+ const onSubagentIndexChange = jest.fn();+ const { result } = renderHook(+ () => useStepHandler({ ...createHookParams(), onSubagentIndexChange }),+ { wrapper: subagentStoreWrapper },+ );+ const submission = createSubmission();++ act(() => {+ for (const phase of ['start', 'run_step_delta', 'stop', 'error'] as const) {+ result.current.stepHandler(+ { event: StepEvents.ON_SUBAGENT_UPDATE, data: makeUpdate({ phase }) },+ submission,+ );+ }+ });+ expect(onSubagentIndexChange.mock.calls).toEqual([['conv-1'], ['conv-1'], ['conv-1']]);++ act(() => {+ result.current.stepHandler(+ { event: StepEvents.ON_SUBAGENT_UPDATE, data: makeUpdate({ phase: 'start' }) },+ createSubmission({+ userMessage: createUserMessage({ conversationId: String(Constants.NEW_CONVO) }),+ initialResponse: createResponseMessage({ conversationId: String(Constants.NEW_CONVO) }),+ }),+ );+ });+ expect(onSubagentIndexChange).toHaveBeenCalledTimes(3);++ act(() => {+ result.current.stepHandler(+ { event: StepEvents.ON_SUBAGENT_UPDATE, data: makeUpdate({ phase: 'start' }) },+ createSubmission({+ userMessage: createUserMessage({ conversationId: String(Constants.NEW_CONVO) }),+ initialResponse: createResponseMessage({ conversationId: 'saved-parent' }),+ }),+ );+ });+ expect(onSubagentIndexChange).toHaveBeenLastCalledWith('saved-parent');+ });+it('correlates updates to a tool call via parentToolCallId (deterministic path)', () => {const { result, getProgress } = renderStepHandlerWithReader();const { submission } = seedResponseWithSubagentToolCalls(result, ['call_A']);diff --git a/client/src/hooks/SSE/useEventHandlers.ts b/client/src/hooks/SSE/useEventHandlers.tsindex c1d801b078..7894ca89e9 100644--- a/client/src/hooks/SSE/useEventHandlers.ts+++ b/client/src/hooks/SSE/useEventHandlers.ts@@ -552,6 +552,12 @@ export default function useEventHandlers({queryClient.invalidateQueries({ queryKey: [key], refetchType: 'all' });}}, [queryClient]);+ const onSubagentIndexChange = useCallback(+ (conversationId: string) => {+ void queryClient.invalidateQueries([QueryKeys.parentSubagents, conversationId]);+ },+ [queryClient],+ );const {stepHandler,clearStepMaps,@@ -568,6 +574,7 @@ export default function useEventHandlers({setIsSubmitting,lastAnnouncementTimeRef,onSkillAuthoringComplete,+ onSubagentIndexChange,});const attachmentHandler = useAttachmentHandler(queryClient);diff --git a/client/src/hooks/SSE/useStepHandler.ts b/client/src/hooks/SSE/useStepHandler.tsindex 7e70de8572..f97c5b603a 100644--- a/client/src/hooks/SSE/useStepHandler.ts+++ b/client/src/hooks/SSE/useStepHandler.ts@@ -57,6 +57,7 @@ type TUseStepHandler = {* invalidation) so this hook stays free of query-client coupling.*/onSkillAuthoringComplete?: () => void;+ onSubagentIndexChange?: (conversationId: string) => void;};type TStepEvent =@@ -159,6 +160,7 @@ export default function useStepHandler({announcePolite,lastAnnouncementTimeRef,onSkillAuthoringComplete,+ onSubagentIndexChange,}: TUseStepHandler) {const subagentStore = useStore();const toolCallIdMap = useRef(new Map<string, string | undefined>());@@ -1376,6 +1378,18 @@ export default function useStepHandler({responseMessageId = submission?.initialResponse?.messageId ?? '';}applySubagentUpdate(stepEvent.data, responseMessageId);+ if (+ stepEvent.data.phase === 'start' ||+ stepEvent.data.phase === 'stop' ||+ stepEvent.data.phase === 'error'+ ) {+ const conversationId = [+ submission?.userMessage?.conversationId,+ submission?.initialResponse?.conversationId,+ submission?.conversation?.conversationId,+ ].find((id) => id && id !== Constants.NEW_CONVO && id !== Constants.PENDING_CONVO);+ if (conversationId) onSubagentIndexChange?.(conversationId);+ }} else if (stepEvent.event === StepEvents.ON_SUMMARIZE_START) {announcePolite({ message: 'summarize_started', isStatus: true });} else if (stepEvent.event === StepEvents.ON_SUMMARIZE_DELTA) {@@ -1494,6 +1508,7 @@ export default function useStepHandler({calculateContentIndex,getCurrentMessages,applySubagentUpdate,+ onSubagentIndexChange,setSandboxStarting,clearSandboxStarting,applyPtcToolCall,