← Back to PRs

#21720: fix(#21546): OpenAI conditional tool-first prompt

by RonySpark open 2026-02-20 08:45 View on GitHub →
commands agents size: S
## Summary Add conditional for OpenAI/xAI models: User action requests = tool call FIRST, text AFTER. No acknowledgments before completion. This ensures proper tool call ordering for OpenAI and Grok models. <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR adds comprehensive support for Grok model families (grok-2, grok-3, grok-4) and introduces a tool-first behavior instruction for OpenAI/xAI models. The changes span three commits: - **Extended Grok model prefix support**: Updated `live-model-filter.ts` to recognize grok-2 and grok-3 model families (previously only grok-4) - **Model definitions registration**: Added `XAI_EXTRA_MODELS` array defining grok-3, grok-3-fast, grok-3-mini, grok-3-mini-fast, and grok-2-1212 with proper configuration including cost, context window, and max tokens - **Responses API support**: Added `applyXaiResponsesApiConfig()` to enable native xAI server-side tools (web_search, x_search, code_execution) - **Tool-first prompt instruction**: Added system prompt guidance directing OpenAI/Grok models to call tools first, then provide text responses The changes ensure users receive clear API-level permission errors instead of silent crashes when their xAI key lacks access to a model, and improve tool call ordering for these model families. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - All changes are well-structured additions with proper test coverage. The new model definitions follow existing patterns, the system prompt addition is non-breaking, and the test suite validates the core functionality. The changes fix real issues (silent crashes, model recognition failures) without modifying existing behavior. - No files require special attention <sub>Last reviewed commit: 84ad852</sub> <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs