🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(agent-runtime): restore early visible output end (#17131)
Rylan Cai164ecc2a36bb
diff --git a/apps/server/src/services/agentRuntime/AgentRuntimeService.ts b/apps/server/src/services/agentRuntime/AgentRuntimeService.tsindex e864d16558f..82c79d84758 100644--- a/apps/server/src/services/agentRuntime/AgentRuntimeService.ts+++ b/apps/server/src/services/agentRuntime/AgentRuntimeService.ts@@ -2660,7 +2660,10 @@ export class AgentRuntimeService {// Create streaming executor contextconst executorContext: RuntimeExecutorContext = {agentConfig: metadata?.agentConfig,- allowEarlyFinalAnswerVisibleOutputEnd: !this.agentFactory,+ // The factory may be a Graph-aware dispatcher that still returns the+ // default agent for ordinary conversations. Keep the early visible+ // output end behavior tied to the actual agent, not factory presence.+ allowEarlyFinalAnswerVisibleOutputEnd: agent instanceof GeneralChatAgent,botContext: metadata?.botContext,botPlatformContext: metadata?.botPlatformContext,discordContext: metadata?.discordContext,diff --git a/apps/server/src/services/agentRuntime/__tests__/executeStep.test.ts b/apps/server/src/services/agentRuntime/__tests__/executeStep.test.tsindex 7cf45687fa4..720f32717d3 100644--- a/apps/server/src/services/agentRuntime/__tests__/executeStep.test.ts+++ b/apps/server/src/services/agentRuntime/__tests__/executeStep.test.ts@@ -1,4 +1,6 @@// @vitest-environment node+import { GeneralChatAgent, GraphAgent } from '@lobechat/agent-runtime';+import type { ReasoningGraph } from '@lobechat/types';import { describe, expect, it, vi } from 'vitest';import { createRuntimeExecutors } from '@/server/modules/AgentRuntime/RuntimeExecutors';@@ -216,6 +218,57 @@ describe('AgentRuntimeService.executeStep - early exit on terminal state', () =>);});+ it('disables early final visible output end for GraphAgent', async () => {+ vi.mocked(createRuntimeExecutors).mockClear();+ const graph = {+ edges: [{ from: '__root__', instruction: 'Answer the user.', to: 'answer' }],+ fields: {},+ name: 'answer-graph',+ nodes: { answer: { type: 'llm' } },+ terminal: 'answer',+ } satisfies ReasoningGraph;+ const service = new AgentRuntimeService({} as any, 'user-1', {+ agentFactory: (config) => new GraphAgent({ ...config, graph }),+ queueService: null,+ });++ await (service as any).createAgentRuntime({+ metadata: {+ agentConfig: {},+ modelRuntimeConfig: { model: 'gpt-test', provider: 'lobehub' },+ userId: 'user-1',+ },+ operationId: 'op-graph-agent',+ stepIndex: 0,+ });++ expect(createRuntimeExecutors).toHaveBeenCalledWith(+ expect.objectContaining({ allowEarlyFinalAnswerVisibleOutputEnd: false }),+ );+ });++ it('allows early final visible output end when a factory returns GeneralChatAgent', async () => {+ vi.mocked(createRuntimeExecutors).mockClear();+ const service = new AgentRuntimeService({} as any, 'user-1', {+ agentFactory: (config) => new GeneralChatAgent(config),+ queueService: null,+ });++ await (service as any).createAgentRuntime({+ metadata: {+ agentConfig: {},+ modelRuntimeConfig: { model: 'gpt-test', provider: 'lobehub' },+ userId: 'user-1',+ },+ operationId: 'op-general-agent',+ stepIndex: 0,+ });++ expect(createRuntimeExecutors).toHaveBeenCalledWith(+ expect.objectContaining({ allowEarlyFinalAnswerVisibleOutputEnd: true }),+ );+ });+it('should NOT skip step when operation status is "running"', async () => {const service = createService();