Skip to content

Fix issue #10729: Add xai/grok-code-fast-1 to MODELS_WITHOUT_STOP_WORDS - #147

Merged
enyst merged 2 commits into
mainfrom
fix-grok-code-fast-1-stop-words
Sep 8, 2025
Merged

enyst merged 2 commits into
mainfrom
fix-grok-code-fast-1-stop-words

Conversation

@enyst

@enyst enyst commented Sep 8, 2025

Copy link
Copy Markdown
Member

End-user friendly description of the problem this fixes or functionality this introduces.

Fixed compatibility issue with the x-ai/grok-code-fast-1 model when used through OpenRouter. Users were experiencing "Client specified an invalid argument: stop" errors because this model doesn't support the stop parameter. The model is now properly configured to work without stop words.


Summarize what the PR does, explaining any non-trivial design decisions.

This PR adds the grok-code-fast-1 model to the SUPPORTS_STOP_WORDS_FALSE_PATTERNS list in openhands/sdk/llm/utils/model_features.py. This prevents the agent-sdk from sending the stop parameter to this model, which doesn't support it.

The fix follows the same pattern as the previous fix for grok-4-0709 and mirrors the changes made to the main OpenHands repository in PR #10867. The model name pattern is added to the list of models that don't support stop words, and comprehensive tests are added to verify the behavior works correctly for both provider-prefixed (xai/grok-code-fast-1) and bare (grok-code-fast-1) model names.

Changes Made:

  • Added grok-code-fast-1 to SUPPORTS_STOP_WORDS_FALSE_PATTERNS in model_features.py
  • Enhanced test coverage in test_model_features.py to include:
    • Tests for both grok-4-0709 and grok-code-fast-1 models
    • Tests for provider-prefixed (xai/) and bare model names
    • Dedicated test functions for grok model stop words behavior

Testing:

  • All 75 existing tests continue to pass
  • New tests specifically verify that grok models return supports_stop_words=False
  • Tests cover both provider-qualified and bare model names

Link of any specific issues this addresses:

This change mirrors the fix applied to the main OpenHands repository in PR OpenHands/OpenHands#10867 for issue OpenHands/OpenHands#10729, ensuring consistency between the main OpenHands codebase and the agent-sdk.

Related:

@enyst can click here to continue refining the PR

- Add grok-code-fast-1 to SUPPORTS_STOP_WORDS_FALSE_PATTERNS list
- Add comprehensive tests for both grok-4-0709 and grok-code-fast-1 models
- Test both provider-prefixed (xai/) and bare model names
- Ensures compatibility with OpenRouter and other providers

This change mirrors the fix applied to the main OpenHands repository
in PR #10867 to maintain consistency across both codebases.
@github-actions

github-actions Bot commented Sep 8, 2025 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report
FileStmtsMissCoverMissing
openhands
   __init__.py10100% 
openhands/sdk
   __init__.py14285%22–23
   logger.py732171%33, 57, 64–67, 69–71, 124, 130–132, 135–136, 142–144, 151, 156–157
openhands/sdk/agent
   __init__.py30100% 
   base.py46491%36, 47, 83, 103
openhands/sdk/agent/agent
   __init__.py20100% 
   agent.py1282878%73–75, 132–133, 135–137, 139–141, 175, 189, 210, 240, 272–277, 284–285, 289–291, 319, 326
openhands/sdk/context
   __init__.py40100% 
   agent_context.py57296%146, 152
   manager.py330%1, 4–5
   view.py47687%46–50, 52
openhands/sdk/context/condenser
   __init__.py30100% 
   condenser.py17382%68–69, 73
   no_op_condenser.py60100% 
openhands/sdk/context/microagents
   __init__.py40100% 
   exceptions.py50100% 
   microagent.py1412979%129, 132–135, 209–215, 218, 223, 245–246, 251–252, 254, 258, 265–267, 275–277, 331, 333–334
   types.py300100% 
openhands/sdk/context/utils
   __init__.py20100% 
   prompt.py30583%12, 15, 24, 44–45
openhands/sdk/conversation
   __init__.py50100% 
   conversation.py83890%70, 78, 86–88, 92–93, 149
   state.py28292%47–48
   types.py30100% 
   visualizer.py1442483%46, 71, 84, 110, 112, 114, 117, 166–168, 171–172, 174, 197, 227, 231, 238, 241, 244–245, 268–270, 272
openhands/sdk/event
   __init__.py60100% 
   base.py642068%34, 38, 49, 53–55, 57–62, 64–65, 67–69, 71–72, 74
   condenser.py25580%29, 33–35, 49
   llm_convertible.py1051486%29–30, 35–36, 174–175, 180, 188, 220–221, 226, 248–249, 254
   types.py30100% 
   user_action.py6183%12
   utils.py110100% 
openhands/sdk/llm
   __init__.py60100% 
   exceptions.py360100% 
   llm.py41413866%269, 274, 287–289, 293–294, 326, 365, 369, 379, 385–386, 403–404, 474, 487–488, 493–494, 496–497, 499–502, 507–509, 513–515, 532–533, 536–538, 541–542, 550–551, 556, 559, 561–562, 566–567, 570–574, 584–587, 592–597, 601–602, 611–613, 616–617, 641, 647–648, 694, 743, 749, 752, 761–762, 771, 778, 781, 785–787, 791, 793–798, 800–817, 820–824, 826–827, 833–842, 846–857
   llm_registry.py380100% 
   message.py100298%201–202
   metadata.py150100% 
openhands/sdk/llm/utils
   fn_call_converter.py34311267%74, 343, 345, 348–349, 367, 369, 375, 381, 383, 422, 424, 426, 428, 433–434, 481–482, 518–520, 522, 524, 545–547, 553, 575, 601–602, 610–613, 615, 617, 639, 648, 656, 701–704, 708–711, 723, 727, 738, 748, 794, 796–798, 800, 803, 819–821, 823–826, 829, 833, 844–845, 859, 866–867, 870–871, 875–876, 882–883, 886, 905–908, 912–913, 918–919, 924, 973–974, 980, 994, 1006, 1008–1009, 1012–1014, 1016–1017, 1023–1025, 1027–1028, 1030, 1032, 1036, 1038, 1043, 1045–1046, 1049
   metrics.py110298%17, 113
   model_features.py400100% 
   telemetry.py116992%71, 94, 99–100, 112–113, 120, 192, 208
openhands/sdk/mcp
   __init__.py50100% 
   client.py631182%41, 56–57, 78, 82, 94–95, 105–106, 112–113
   definition.py27196%54
   tool.py381365%33–36, 40, 43, 46–49, 89–90, 95
   utils.py30486%23–24, 27, 30
openhands/sdk/tool
   __init__.py40100% 
   schema.py89693%19–21, 23, 32, 191
   security_prompt.py30100% 
   tool.py821186%51, 107, 129, 149, 152–158
openhands/sdk/tool/builtins
   __init__.py30100% 
   finish.py150100% 
openhands/sdk/utils
   __init__.py20100% 
   json.py28280%1–3, 5, 7–8, 11, 14–21, 25, 28, 30–31, 34, 37–38, 40, 43, 45–48
   truncate.py100100% 
openhands/tools
   __init__.py8275%37–38
openhands/tools/execute_bash
   __init__.py40100% 
   constants.py90100% 
   definition.py411465%65, 69–78, 148, 151, 159
   impl.py10190%38
   metadata.py502354%67–73, 77–78, 83, 85, 87–96, 100–101
openhands/tools/execute_bash/terminal
   __init__.py60100% 
   factory.py492842%24–25, 30, 32, 35, 37–38, 44–46, 74–77, 79–83, 87–89, 91, 97, 107, 111–113
   interface.py661675%43, 52, 62, 71, 76, 85, 94, 99, 104, 112, 145, 157, 162, 171, 180, 185
   subprocess_terminal.py23620313%33–34, 50–53, 56, 59–61, 67–68, 70–73, 75, 78, 80–82, 96–99, 101, 104–105, 108, 111–112, 116–117, 123–125, 127, 130–131, 133, 137–138, 140–141, 143–149, 151–157, 160–165, 167–168, 170–171, 176, 178–186, 190–192, 194–195, 197–198, 201–203, 205–208, 210–211, 213–214, 216–221, 226–228, 230, 233, 236–237, 240–241, 247–249, 251–258, 260–263, 267–275, 288–289, 291, 308–309, 312–313, 315, 317, 319–321, 324–325, 327–329, 331–332, 334–335, 344–345, 349, 351–356, 360–361, 363–366, 368–374, 376–377, 379–383, 387–388, 390–396, 400–401, 404–405, 407–408, 410–412
   terminal_session.py17813623%43, 86, 92, 96–98, 107–108, 119–121, 123–126, 135–136, 140, 144, 147–148, 150, 155, 161, 163–164, 169, 177, 182–185, 198–200, 205, 208–209, 213, 219, 233–235, 240, 243–244, 248, 255, 264, 273–274, 276, 279–283, 285, 288, 290–292, 296–297, 300–302, 306, 311–312, 316–317, 323–325, 336–337, 340–342, 344–346, 349, 359, 363, 366, 369–370, 376–377, 383, 388–389, 392–396, 402, 404–406, 412–416, 419, 422, 425–426, 428–431, 438, 442, 447–448, 455–457, 461, 465, 470–471, 475–476, 479–482, 488–489, 492
   tmux_terminal.py752764%35, 41, 85, 97–98, 100, 108–109, 111, 118, 123, 135–142, 150–151, 153–154, 156, 158–160
openhands/tools/execute_bash/utils
   command.py817211%15–19, 27, 32, 34–35, 37–38, 41–46, 48, 51–53, 55, 58–67, 74–75, 77–79, 81, 83, 90–91, 93, 95–97, 99, 101–102, 105–106, 109, 117, 120–121, 123–124, 127–129, 132–138, 141–145, 150
openhands/tools/str_replace_editor
   __init__.py30100% 
   definition.py33487%78, 145, 148, 151
   editor.py22817025%74, 76–77, 80, 99, 102, 111–115, 121–129, 131, 149–150, 170–171, 175, 179–180, 189, 193–196, 204–205, 209–211, 217, 220, 225, 228, 231–232, 235, 238–239, 243, 247, 261–263, 272, 275, 281, 286, 288–292, 294, 296, 300–301, 305–306, 314–315, 317–320, 322, 328–329, 335–337, 345–349, 353, 355–356, 363, 366, 371–372, 374, 397–398, 420–421, 423–424, 430, 433, 437–443, 446–447, 450–455, 458, 461–462, 466, 469–470, 473, 475–476, 482, 486, 504, 509–512, 514, 522, 529, 536, 547–550, 552, 554, 580–583, 592–593, 622–624, 626–635, 640–643, 656–657, 662, 667, 673, 679
   exceptions.py221340%5–6, 9, 16–18, 25–27, 38–41
   impl.py261157%31–32, 49–50, 52–54, 63–66
openhands/tools/str_replace_editor/utils
   __init__.py00100% 
   config.py20100% 
   constants.py50100% 
   encoding.py542750%42–43, 46–48, 51, 54, 60, 64–65, 67, 69, 78, 80–81, 84, 87–90, 93, 96–97, 114, 128, 130–131
   file_cache.py954849%43–46, 49–50, 54, 59, 61, 64, 69, 72–73, 87, 95–98, 108–112, 115–120, 126–130, 133–135, 138–140, 143–148, 151, 154
   history.py663645%58–60, 66–68, 70–71, 74–76, 78–79, 82, 85–86, 88, 92–94, 98–99, 102–104, 107, 111–113, 115–120, 122
   shell.py231630%30, 32–34, 38, 40, 51–55, 62–63, 70–72
openhands/tools/utils
   __init__.py00100% 
TOTAL4086136166% 

@openhands-ai

openhands-ai Bot commented Sep 8, 2025

Copy link
Copy Markdown

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • Pre-commit checks

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #147 at branch `fix-grok-code-fast-1-stop-words`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

@enyst

enyst commented Sep 8, 2025

Copy link
Copy Markdown
Member Author

@OpenHands precommit checks are failing, please run it correctly per instructions in this repo and fix.

@openhands-ai

openhands-ai Bot commented Sep 8, 2025

Copy link
Copy Markdown

I'm on it! enyst can track my progress at all-hands.dev

🟡 Solvability: MEDIUM

MEDIUM: The issue points to failing pre-commit checks and references existing repo instructions, but it lacks the actual error output, steps taken, and environment context needed to diagnose and fix the problem. Providing the precise failure details should make this reasonably tractable.

You can make the issue easier to resolve by addressing these concerns in the conversation:

  • Share the exact command you ran and paste the full output/logs from the failing pre-commit run.
  • Include relevant configuration and environment info: .pre-commit-config.yaml, tool versions (pre-commit, Python), OS/shell, and any local overrides.
  • Describe the steps you followed from the repo instructions and note any recent changes that might affect the hooks (e.g., dependency updates or config edits).

Positive feedback:

  • The issue is scoped to a specific workflow (pre-commit checks), which helps narrow the investigation.
  • Referencing the repository’s instructions suggests there is a known process to follow, aiding reproducibility.

Co-authored-by: openhands <openhands@all-hands.dev>
@openhands-ai

openhands-ai Bot commented Sep 8, 2025

Copy link
Copy Markdown

Summary

I successfully fixed the pre-commit check failures in PR #147. Here's what I accomplished:

Issue Identified: The pre-commit checks were failing due to an E501 "Line too long" error in tests/sdk/llm/test_model_features.py. The docstring in the test_stop_words_grok_provider_prefixed() function exceeded the 88-character line limit (92 characters).

Solution Applied: Following the repository's instructions for handling long docstrings, I added # noqa: E501 after the ending """ to suppress the line length check for that specific docstring.

Changes Made:

  • Modified line 251 in tests/sdk/llm/test_model_features.py to add the noqa comment
  • Committed the fix with proper co-authorship attribution
  • Pushed the changes to update the PR

Verification:
✅ All pre-commit hooks now pass:

  • Ruff format: Passed
  • Ruff lint: Passed
  • PEP8 style check: Passed
  • Type check with Pyright: Passed

✅ The new grok model tests continue to work correctly
✅ The fix follows the repository's coding standards

The PR should now pass all GitHub Actions pre-commit checks. The change was minimal and targeted - only adding the necessary noqa comment to resolve the line length violation without affecting any functionality.

View full conversation

@enyst

enyst commented Sep 8, 2025

Copy link
Copy Markdown
Member Author

This is a small thing, I’m going to merge it to get it out of the way. 🫣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant