Files
miti99bot/tests
tiennm99 0887a07367 fix(twentyq): drop function calling, use JSON-in-content for Gemma 4 compat
Gemma 4 likely rejects the flat "traditional" tools schema we were sending
(the docs use OpenAI-wrapped shape for this model) — causing env.AI.run to
throw and users to see the "AI service hiccup" reply every turn.

Switch to the universal approach:
- system prompt asks the model for a one-line JSON {is_guess, answer, hint}
- ai-client.extractText handles both Workers-AI and OpenAI response shapes
- parseJudgementJson walks brace-depth to extract JSON from stray prose /
  accidental code fences
- logs twentyq_ai_throw / twentyq_ai_unparseable with preview on failure
  so future issues surface in wrangler tail immediately

Tests: 7 new (parser + extractText); 444 total pass.
2026-04-24 14:57:58 +07:00
..