diff --git a/agentex-ui/components/task-header/investigate-traces-button.tsx b/agentex-ui/components/task-header/investigate-traces-button.tsx index 7663ab89..aabc26e6 100644 --- a/agentex-ui/components/task-header/investigate-traces-button.tsx +++ b/agentex-ui/components/task-header/investigate-traces-button.tsx @@ -5,6 +5,7 @@ import { forwardRef } from 'react'; import { ArrowRight } from 'lucide-react'; import { useAgentexClient } from '@/components/providers'; +import { useSafeSearchParams } from '@/hooks/use-safe-search-params'; import { cn } from '@/lib/utils'; type InvestigateTracesButtonProps = { @@ -18,7 +19,16 @@ export const InvestigateTracesButton = forwardRef< InvestigateTracesButtonProps >(({ className, disabled = false, traceId, ...props }, ref) => { const { sgpAppURL } = useAgentexClient(); - const sgpTracesURL = `${sgpAppURL}/beta/monitor?trace_id=${traceId}&tt-trace-id=${traceId}`; + const { sgpAccountID } = useSafeSearchParams(); + + const params = new URLSearchParams({ + trace_id: traceId, + 'tt-trace-id': traceId, + }); + if (sgpAccountID) { + params.set('account_id', sgpAccountID); + } + const sgpTracesURL = `${sgpAppURL}/monitor?${params.toString()}`; if (!sgpAppURL) { return null;