Skip to content

Commit 5e4e528

Browse files
simbasimba
authored andcommitted
fix(benchmark): add JSON guidance suffix and sanitize null message content
- Append JSON-only instruction to last user message for local models - Replace null content with empty string for llama-server compatibility
1 parent e5a4bfa commit 5e4e528

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎skills/analysis/home-security-benchmark/scripts/run-benchmark.cjs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,23 @@ async function llmCall(messages, opts = {}) {
178178
}
179179
return m;
180180
});
181+
// Append JSON guidance to last user message for local models
182+
const lastUser = messages.findLastIndex(m => m.role === 'user');
183+
if (lastUser >= 0 && typeof messages[lastUser].content === 'string') {
184+
messages[lastUser] = {
185+
...messages[lastUser],
186+
content: messages[lastUser].content + '\n\nRespond with ONLY valid JSON, no explanation or markdown.',
187+
};
188+
}
181189
}
182190

191+
// Sanitize messages for llama-server compatibility:
192+
// - Replace null content with empty string (llama-server rejects null)
193+
messages = messages.map(m => ({
194+
...m,
195+
...(m.content === null && { content: '' }),
196+
}));
197+
183198
// Build request params
184199
const params = {
185200
messages,

0 commit comments

Comments
 (0)