🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(in-app-agent): delay feedback controls until turn ends (#14961)
Lysander Kiesel1ca90e78e635
diff --git a/web/src/ee/features/in-app-agent/components/ControlledInAppAgentWindow.tsx b/web/src/ee/features/in-app-agent/components/ControlledInAppAgentWindow.tsxindex f831fecb5a..9d923bf04e 100644--- a/web/src/ee/features/in-app-agent/components/ControlledInAppAgentWindow.tsx+++ b/web/src/ee/features/in-app-agent/components/ControlledInAppAgentWindow.tsx@@ -67,6 +67,7 @@ export function ControlledInAppAgentWindow(return (<InAppAgentWindowerror={error}+ isAssistantTurnInProgress={isRunning || pendingToolApprovals.length > 0}isHeaderDragHandleEnabled={props.isHeaderDragHandleEnabled}isExpanded={props.isExpanded}isInputDisabled={isInputDisabled}diff --git a/web/src/ee/features/in-app-agent/components/InAppAgentWindow.stories.tsx b/web/src/ee/features/in-app-agent/components/InAppAgentWindow.stories.tsxindex 950c93ecdb..d85933f237 100644--- a/web/src/ee/features/in-app-agent/components/InAppAgentWindow.stories.tsx+++ b/web/src/ee/features/in-app-agent/components/InAppAgentWindow.stories.tsx@@ -508,6 +508,7 @@ const meta = preview.meta({conversations,hasMoreConversations: false,isLoadingMoreConversations: false,+ isAssistantTurnInProgress: false,selectedConversationId: undefined,onDeleteConversation: fn(),onLoadMoreConversations: fn(),@@ -850,6 +851,90 @@ export const LoadingAfterToolCall = meta.story({},});+export const FeedbackControlsWaitForTurnEnd = meta.story({+ name: "(Test) Feedback Controls Wait For Turn End",+ args: {+ selectedConversationId: "conversation-1",+ isInputDisabled: true,+ isAssistantTurnInProgress: true,+ onSubmitFeedback: fn(),+ messages: [+ {+ id: "user-1",+ role: "user",+ content: {+ type: "text",+ text: "Summarize recent ingestion errors.",+ },+ },+ {+ id: "assistant-1",+ runId: "run-1",+ role: "assistant",+ content: {+ type: "text",+ text: "I found a cluster of ingestion errors around malformed JSON payloads",+ },+ },+ ],+ },+ play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {+ const canvas = within(canvasElement);++ await canvas.findByText(+ "I found a cluster of ingestion errors around malformed JSON payloads",+ );++ await waitFor(() => {+ expect(+ canvas.queryByRole("button", { name: "Good response" }),+ ).not.toBeInTheDocument();+ expect(+ canvas.queryByRole("button", { name: "Bad response" }),+ ).not.toBeInTheDocument();+ });+ },+});++export const FeedbackControlsShowAfterTurnEnd = meta.story({+ name: "(Test) Feedback Controls Show After Turn End",+ args: {+ selectedConversationId: "conversation-1",+ isInputDisabled: false,+ isAssistantTurnInProgress: false,+ onSubmitFeedback: fn(),+ messages: [+ {+ id: "user-1",+ role: "user",+ content: {+ type: "text",+ text: "Summarize recent ingestion errors.",+ },+ },+ {+ id: "assistant-1",+ runId: "run-1",+ role: "assistant",+ content: {+ type: "text",+ text: "The errors were caused by malformed JSON payloads.",+ },+ },+ ],+ },+ play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {+ const canvas = within(canvasElement);++ await expect(+ canvas.findByRole("button", { name: "Good response" }),+ ).resolves.toBeInTheDocument();+ await expect(+ canvas.findByRole("button", { name: "Bad response" }),+ ).resolves.toBeInTheDocument();+ },+});+export const Connecting = meta.story({args: {isInputDisabled: true,diff --git a/web/src/ee/features/in-app-agent/components/InAppAgentWindow.tsx b/web/src/ee/features/in-app-agent/components/InAppAgentWindow.tsxindex b8bd08a1c9..d73927cfb3 100644--- a/web/src/ee/features/in-app-agent/components/InAppAgentWindow.tsx+++ b/web/src/ee/features/in-app-agent/components/InAppAgentWindow.tsx@@ -90,6 +90,7 @@ export type InAppAgentWindowProps = {conversations: InAppAgentWindowConversation[];error: string | null;hasMoreConversations: boolean;+ isAssistantTurnInProgress: boolean;isHeaderDragHandleEnabled?: boolean;isExpanded: boolean;isInputDisabled: boolean;@@ -118,6 +119,7 @@ export function InAppAgentWindow(props: InAppAgentWindowProps) {conversations,error,hasMoreConversations,+ isAssistantTurnInProgress,isHeaderDragHandleEnabled = false,isExpanded,isInputDisabled,@@ -497,12 +499,15 @@ export function InAppAgentWindow(props: InAppAgentWindowProps) {nextUserMessageIndex === -1? visibleMessages.length: nextUserMessageIndex;+ const isCurrentTurnInProgress =+ isAssistantTurnInProgress && nextUserMessageIndex === -1;const isLastMessageOfTurn = visibleMessages.slice(index + 1, nextTurnStartIndex).every((nextMessage) => nextMessage.role !== "assistant");const feedbackRunId =message.role === "assistant" &&message.content.type === "text" &&+ !isCurrentTurnInProgress &&isLastMessageOfTurn? message.runId: undefined;