Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions app/debug/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,14 @@ const getStreamingEventText = (event: unknown): string | null => {
const choiceText = getText(event.choices);
if (choiceText) return choiceText;

return event.type === 'response.output_text.delta'
? getText(event.delta)
: null;
if (
event.type === 'response.output_text.delta' ||
event.type === 'content_block_delta'
) {
return getText(event.delta);
}

return null;
};

const getToolName = (tool: JsonRecord): string => {
Expand Down Expand Up @@ -293,12 +298,19 @@ const formatToolName = (value: string): string => {
.join(' ');
};

const getResponseFormat = (route: string): string => {
const getDownstreamFormat = (route: string): string => {
if (route === '/v1/responses') return 'OpenAI Responses';
if (route === '/v1/messages') return 'Anthropic Messages';
return 'OpenAI Chat';
};

const getUpstreamFormat = (
upstreamRequest: DebugLogEntry['upstreamRequest'],
): string => {
if (upstreamRequest?.url.endsWith('/responses')) return 'OpenAI Responses';
return 'OpenAI Chat';
Comment on lines +310 to +311

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle absent upstream requests without claiming Chat

When a request fails before an upstream call—such as /v1/messages with no messages—the finalized trace retains upstreamRequest: null, but this fallback labels both upstream sections as OpenAI Chat. That makes the diagnostic UI claim a protocol that was never used; return an unknown/not-sent format for null requests instead.

Useful? React with 👍 / 👎.

};

const formatMaskedRequestKey = (value: string): string => {
return value.replace(/^Bearer\s+/i, '').replaceAll('...', '****');
};
Expand Down Expand Up @@ -883,7 +895,7 @@ const Debug = () => {
const formatOptions = useMemo(
() =>
[
...new Set(debug.items.map((item) => getResponseFormat(item.route))),
...new Set(debug.items.map((item) => getDownstreamFormat(item.route))),
].map((format) => ({ label: format, value: format })),
[debug.items],
);
Expand Down Expand Up @@ -932,7 +944,7 @@ const Debug = () => {
const filteredItems = useMemo(
() =>
debug.items.filter((item) => {
const format = getResponseFormat(item.route);
const format = getDownstreamFormat(item.route);
const credential = item.credentialFilename ?? EMPTY_FILTER_VALUE;
const model = item.model ?? EMPTY_FILTER_VALUE;
const requestKey = item.requestKey ?? EMPTY_FILTER_VALUE;
Expand Down Expand Up @@ -1152,25 +1164,25 @@ const Debug = () => {
) : (
<>
<RawDebugSection
format={getResponseFormat(item.route)}
format={getDownstreamFormat(item.route)}
step={1}
title={debugText('request')}
value={item.requestBody}
/>
<StructuredUpstreamRequest
format={getResponseFormat(item.route)}
format={getUpstreamFormat(item.upstreamRequest)}
step={2}
title={debugText('upstreamRequest')}
value={item.upstreamRequest?.body}
/>
<StructuredResponse
format={getResponseFormat(item.route)}
format={getUpstreamFormat(item.upstreamRequest)}
step={3}
title={debugText('upstreamResponse')}
value={item.upstreamResponse?.body}
/>
<StructuredResponse
format={getResponseFormat(item.route)}
format={getDownstreamFormat(item.route)}
step={4}
title={debugText('response')}
value={item.transformedResponse?.body}
Expand Down
Loading