Problem
apps/desktop/src/main/gateway/bridge/input.ts L236–246
export function stripReasoningContent(input: unknown): unknown {
if (!Array.isArray(input)) return input;
const str = JSON.stringify(input); // ← serializes entire conversation history
if (!str.includes('reasoning_content')) return input; // only checks for field existence
return input.map((item) => { ... });
}
The conversation history can contain dozens of message turns and large blocks of code or tool output, yet this code serializes the whole array just to perform a substring check for a field name.
Suggested fix
if (!Array.isArray(input) || !input.some(
(item) => item && typeof item === 'object' && 'reasoning_content' in item
)) return input;
Eliminates JSON.stringify entirely; direct property access short-circuits as soon as a match is found.
Problem
apps/desktop/src/main/gateway/bridge/input.tsL236–246The conversation history can contain dozens of message turns and large blocks of code or tool output, yet this code serializes the whole array just to perform a substring check for a field name.
Suggested fix
Eliminates
JSON.stringifyentirely; direct property access short-circuits as soon as a match is found.