🪢 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(agent): Small improvements (#14248)
Ben Bachem08bc9632c623
diff --git a/web/src/ee/features/in-app-agent/components/InAppAgentMessage.module.css b/web/src/ee/features/in-app-agent/components/InAppAgentMessage.module.cssnew file mode 100644index 0000000000..f04f9cb4ad--- /dev/null+++ b/web/src/ee/features/in-app-agent/components/InAppAgentMessage.module.css@@ -0,0 +1,105 @@+@reference "../../../../styles/globals.css";++.Streamdown {+ @apply prose prose-sm text-foreground prose-headings:text-inherit prose-headings:text-sm max-w-none;+}++.Streamdown.compact {+ @apply prose-headings:my-2 text-[0.775rem] leading-4;+}++.Streamdown:not(.compact) {+ @apply prose-headings:my-2.5 text-sm leading-4.5;+}++.Streamdown > div > *:first-child {+ @apply mt-0!;+}++.Streamdown > div > *:last-child {+ @apply mb-0!;+}++.Streamdown pre {+ @apply bg-muted text-foreground dark:bg-card leading-tight;+}++.Streamdown code {+ @apply text-foreground bg-muted dark:bg-card rounded px-1 py-px font-normal before:content-[''] after:content-[''];+}++.Streamdown strong {+ @apply text-inherit;+}++.Streamdown table {+ @apply bg-muted dark:bg-card m-0! overflow-hidden rounded border;+}++.Streamdown td {+ @apply p-2;+}++.Streamdown th {+ @apply p-2;+}++.Streamdown tr {+ @apply border-border dark:border-border border-b;+}++.Streamdown hr {+ @apply border-border;+}++.Streamdown pre > code {+ @apply p-0;+}++.Streamdown.compact ul,+.Streamdown.compact ol,+.Streamdown.compact p {+ @apply my-1;+}++.Streamdown.compact li {+ @apply my-0.5;+}++.Streamdown.compact th {+ @apply text-xs;+}++.Streamdown.compact hr {+ @apply my-3;+}++.Streamdown.compact blockquote,+.Streamdown.compact pre,+.Streamdown.compact table {+ @apply my-2;+}++.Streamdown:not(.compact) ul,+.Streamdown:not(.compact) ol,+.Streamdown:not(.compact) p {+ @apply my-1.5;+}++.Streamdown:not(.compact) li {+ @apply my-1;+}++.Streamdown:not(.compact) th {+ @apply text-sm;+}++.Streamdown:not(.compact) hr {+ @apply my-5;+}++.Streamdown:not(.compact) blockquote,+.Streamdown:not(.compact) pre,+.Streamdown:not(.compact) table {+ @apply my-2.5;+}diff --git a/web/src/ee/features/in-app-agent/components/InAppAgentMessage.stories.tsx b/web/src/ee/features/in-app-agent/components/InAppAgentMessage.stories.tsxindex de4471671a..5ed83e8508 100644--- a/web/src/ee/features/in-app-agent/components/InAppAgentMessage.stories.tsx+++ b/web/src/ee/features/in-app-agent/components/InAppAgentMessage.stories.tsx@@ -82,7 +82,7 @@ export const AssistantMarkdown = meta.story({"##### Heading 5","###### Heading 6","",- "You can use **Langfuse** to inspect _production traces_ and compare `input`, `output`, and metadata across releases.",+ "You can use **Langfuse** to inspect _production traces_ and compare `input`, `output`, `metadata` and `scores` across releases.","","- Inspect traces with nested observations","- Evaluate outputs with scores",diff --git a/web/src/ee/features/in-app-agent/components/InAppAgentMessage.tsx b/web/src/ee/features/in-app-agent/components/InAppAgentMessage.tsxindex 153a3f7f6c..660f9d148f 100644--- a/web/src/ee/features/in-app-agent/components/InAppAgentMessage.tsx+++ b/web/src/ee/features/in-app-agent/components/InAppAgentMessage.tsx@@ -1,6 +1,13 @@"use client";-import { Loader2, ThumbsDown, ThumbsUp, Wrench } from "lucide-react";+import {+ Check,+ Copy,+ Loader2,+ ThumbsDown,+ ThumbsUp,+ Wrench,+} from "lucide-react";import { Streamdown } from "streamdown";import { getSafeLinkUrl } from "@/src/components/ui/safe-url";import { cn } from "@/src/utils/tailwind";@@ -22,7 +29,9 @@ import {PopoverContent,} from "@/src/components/ui/popover";import { useElementSize } from "@/src/hooks/useElementSize";+import { useCopyToClipboard } from "@/src/hooks/useCopyToClipboard";import { useWatchedPromiseCallback } from "@/src/hooks/useWatchedPromiseCallback";+import styles from "./InAppAgentMessage.module.css";export type InAppAgentMessageRole = "assistant" | "user";@@ -432,7 +441,7 @@ function ToolCallGroup({) : (<Wrench className={cn("text-muted-foreground shrink-0", iconSize)} />)}- <span className="min-w-0 flex-1 truncate">{label}</span>+ <span className="min-w-0 flex-1 truncate py-0.5">{label}</span><span className="text-muted-foreground text-xs group-open/tool-group:hidden">Show</span>@@ -460,7 +469,7 @@ function ToolCallDetails({ tool }: { tool: InAppAgentToolCallContent }) {<details className="group/tool min-w-0"><summary className="flex cursor-pointer list-none items-center gap-2 text-xs leading-none font-medium [&::-webkit-details-marker]:hidden"><Wrench className="text-muted-foreground h-3.5 w-3.5 shrink-0" />- <span className="min-w-0 flex-1 truncate">Used {tool.name}</span>+ <span className="min-w-0 flex-1 truncate py-0.5">Used {tool.name}</span><span className="text-muted-foreground text-xs group-open/tool:hidden">Show</span>@@ -544,12 +553,8 @@ function MessageText({return (<div- className={cn(- "prose prose-sm text-foreground prose-strong:text-inherit prose-pre:bg-muted prose-pre:text-foreground prose-code:text-foreground prose-table:m-0! prose-headings:text-inherit dark:prose-pre:bg-card prose-pre:leading-tight prose-table:border prose-td:p-2 prose-th:p-2 prose-table:bg-muted dark:prose-table:bg-card prose-table:overflow-hidden prose-table:rounded prose-tr:border-b prose-tr:border-border dark:prose-tr:border-border prose-headings:text-sm prose-hr:border-border prose-code:before:content-[''] prose-code:after:content-[''] prose-code:bg-muted prose-code:rounded prose-code:px-1.5 prose-code:py-1 dark:prose-code:bg-card prose-code:font-normal max-w-none [&_pre>code]:p-0",- isCompact- ? "prose-headings:my-2 prose-p:my-1 prose-ul:my-1 prose-li:my-0.5 prose-ol:my-1 prose-blockquote:my-2 prose-pre:my-2 prose-table:my-2 prose-th:text-xs prose-hr:my-3 text-[0.775rem] leading-4"- : "prose-headings:my-2.5 prose-p:my-1.5 prose-ul:my-1.5 prose-li:my-1 prose-ol:my-1.5 prose-blockquote:my-2.5 prose-pre:my-2.5 prose-table:my-2.5 prose-th:text-sm prose-hr:my-5 leading-4.5",- )}+ data-compact={isCompact}+ className={cn(styles.Streamdown, isCompact && styles.compact)}><Streamdown// Remove all default classNames so that tailwind's prose styling can be applied without conflicts@@ -588,7 +593,7 @@ function MessageText({i: ({ children }) => <i>{children}</i>,em: ({ children }) => <em>{children}</em>,code: ({ children }) => <code>{children}</code>,- pre: ({ children }) => <pre>{children}</pre>,+ pre: ({ children }) => <CodeBlock>{children}</CodeBlock>,thead: ({ children }) => <thead>{children}</thead>,tbody: ({ children }) => <tbody>{children}</tbody>,tr: ({ children }) => <tr>{children}</tr>,@@ -607,6 +612,47 @@ function MessageText({);}+function CodeBlock({ children }: { children: ReactNode }) {+ const { copy, isCopied } = useCopyToClipboard({ successDuration: 1_500 });++ // This is ugly but streamdown doesn't provide an easy way to get the raw text content of a code block+ const code = useMemo(+ () =>+ typeof children === "object" &&+ children &&+ "props" in children &&+ typeof children.props === "object" &&+ children.props &&+ "children" in children.props &&+ typeof children.props.children === "string"+ ? children.props.children+ : "",+ [children],+ );++ return (+ <pre className="group/code-block relative pr-10">+ <button+ type="button"+ aria-label={isCopied ? "Copied code" : "Copy code"}+ title={isCopied ? "Copied" : "Copy code"}+ disabled={!code}+ onClick={() => {+ copy(code).catch(() => undefined);+ }}+ className="bg-background/90 text-muted-foreground hover:text-foreground focus-visible:ring-ring absolute top-1.5 right-1.5 z-10 inline-flex size-6 items-center justify-center rounded-md border opacity-80 shadow-sm transition hover:opacity-100 focus-visible:ring-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40"+ >+ {isCopied ? (+ <Check className="size-3.5" />+ ) : (+ <Copy className="size-3.5" />+ )}+ </button>+ {children}+ </pre>+ );+}+function ThinkingIndicator({className,label = "Thinking...",diff --git a/web/src/ee/features/in-app-agent/components/InAppAgentWindow.tsx b/web/src/ee/features/in-app-agent/components/InAppAgentWindow.tsxindex a712c11fc8..4ae9a54e10 100644--- a/web/src/ee/features/in-app-agent/components/InAppAgentWindow.tsx+++ b/web/src/ee/features/in-app-agent/components/InAppAgentWindow.tsx@@ -382,11 +382,23 @@ export function InAppAgentWindow(props: InAppAgentWindowProps) {) : null}<ol className="flex w-full flex-col gap-3 pb-4">- {messages.map((message) => {+ {messages.map((message, index) => {const hasToolContent = message.content.type === "toolGroup";+ const nextUserMessageIndex = messages.findIndex(+ (nextMessage, nextIndex) =>+ nextIndex > index && nextMessage.role === "user",+ );+ const nextTurnStartIndex =+ nextUserMessageIndex === -1+ ? messages.length+ : nextUserMessageIndex;+ const isLastMessageOfTurn = messages+ .slice(index + 1, nextTurnStartIndex)+ .every((nextMessage) => nextMessage.role !== "assistant");const feedbackRunId =message.role === "assistant" &&- message.content.type === "text"+ message.content.type === "text" &&+ isLastMessageOfTurn? message.runId: undefined;diff --git a/web/src/ee/features/in-app-agent/server/agent.ts b/web/src/ee/features/in-app-agent/server/agent.tsindex 925de20ae3..db85cbc156 100644--- a/web/src/ee/features/in-app-agent/server/agent.ts+++ b/web/src/ee/features/in-app-agent/server/agent.ts@@ -27,12 +27,22 @@ If you are not confident in the answer, say that directly instead of guessing.Focus on answering the user's questions. Do not comment on your own behavior:- Do not comment on tools you are using or will use.- Do not comment on the process you are following.+Do not mention variable names, function names or entity names in normal conversation unless the user specifically asks for them.+Avoid messages such as "I'll search the Langfuse documentation for information about X." or "Let me search the documentation for you.".Always provide a complete answer to the user's question in your response, do not rely on users seeing tool input or output.If a tool call fails but you intend on re-trying it, do not mention the failure and just retry the tool call.If you cannot provide an answer to the user, spare the user the details of failed tool calls and instead summarize the issue.If you think it would be helpful, ask the user for clarification or follow up questions to guide them.+Be concise, factual, and useful. Unless asked for a detailed explanation, keep your answers short and to the point.+Use markdown in your responses when appropriate, especially for tables and lists.+IMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.+IMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.</behavioral_rules>+<tools>+Use the docs tools to find relevant general information about Langfuse or best practices.+</tools>+<permissions>Currently, you only have read access to user's project. All your tools enforce this restriction so no need to worry about it.If the user asks you to perform an action, you have two options:@@ -40,11 +50,6 @@ If the user asks you to perform an action, you have two options:- If the action is available via the CLI, suggest that the user can ask their own agent (Claude, Codex or similar) to perform the action for them using the CLI, for that they should use the Langfuse skill: https://github.com/langfuse/skills. When suggesting this, provide a prompt the user can use as a code block.</permissions>-<style_rules>-Be concise, factual, and useful. Unless asked for a detailed explanation, keep your answers short and to the point.-Use markdown in your responses when appropriate, especially for tables and lists.-</style_rules>-<world_knowledge>The current time is ${new Date().toDateString()}.</world_knowledge>