Skip to content

fix(swe-smith): support native tool calls and thinking - #684

Open
Zhengyang Liu (liuzhengyang699) wants to merge 1 commit into
microsoft:mainfrom
liuzhengyang699:fix/code-qwen35-tool-thinking
Open

Zhengyang Liu (liuzhengyang699) wants to merge 1 commit into
microsoft:mainfrom
liuzhengyang699:fix/code-qwen35-tool-thinking

Conversation

@liuzhengyang699

Copy link
Copy Markdown

I found this while reproducing the Coding Agent example with Qwen3.5: the harness cannot consume native tool calls, and every request forces enable_thinking=False.

The loop currently reads only message.content and looks for a fenced Bash command. A normal native-tool response can have content=null and an execute_bash call in tool_calls, so it is treated as a format error and never runs. The harness also drops reasoning from the assistant history, while the example configuration forces the Hermes template/parser instead of Qwen3.5's native format.

This adds two opt-in rollout settings, SMITH_USE_TOOLS and SMITH_ENABLE_THINKING. Native mode advertises one execute_bash(command) tool, validates the call, and returns observations with the matching tool-call ID. It retains both reasoning field aliases for compatibility with the pinned vLLM stack and the native Qwen template. The existing command restrictions, submission detection, and turn accounting still apply; the default Bash prompts are preserved.

The regression tests also cover unfinished reasoning, invalid arguments, unknown or parallel calls, and recovery after a format error. Calls whose arguments cannot be rendered in the next request end the rollout cleanly instead of repeatedly failing at the server. The documentation explains the rollout Job settings and the native-template/qwen3_coder/qwen3 overrides needed for both coding examples.

Related to #519: this addresses the coding harness's tool/thinking workflow, rather than general Qwen3.5 model loading.

Validation

Using Python 3.12 and the locked development dependencies, including verl-cpu:

  • uv run --locked --no-sync pytest -v --durations=20 tests — 281 passed, 4 skipped.
  • uv run --locked --no-sync pyright — no errors or warnings.
  • uv run --locked --no-sync pre-commit run --all-files --show-diff-on-failure — passed.
  • uv run --locked --no-sync ruff check . and uv run --locked --no-sync ruff format --check . — passed.
  • uv run --locked --no-sync python scripts/check_headers.py — passed.
  • UV_PROJECT_ENVIRONMENT=/tmp/agent-lightning-qwen35-docs uv run --locked --no-sync mkdocs build --strict — passed with the locked docs dependencies in a separate environment.
  • uv build --no-sources and git diff --cached --check — passed.

I have not run a live Qwen3.5 inference server, Kubernetes rollout, or GPU training job for this patch. The automated tests use mocked completions; they do not establish training performance.

I used AI assistance to investigate the problem I encountered during reproduction, implement the fix, and write and run the regression tests.

@liuzhengyang699

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@liuzhengyang699
Zhengyang Liu (liuzhengyang699) marked this pull request as ready for review November 7, 2026 06:30
Copilot AI balanced review requested due to automatic review settings November 7, 2026 06:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

With thinking enabled in Bash mode, valid fenced commands are rejected when the server returns null reasoning but accepted with empty reasoning, requiring a parsing fix and regression coverage.

1 open issue
What changed in this PR

Adds opt-in native tool calling and thinking to the SWE-Smith coding harness, addressing the Qwen3.5 workflow discussed in #519 without changing the default fenced-Bash mode.

Changes:

  • Validates execute_bash calls, links tool observations, and preserves reasoning in conversation history.
  • Adds rollout settings and documents native-template and parser configuration for both coding examples.
  • Adds regression tests for tool validation, reasoning handling, error recovery, and legacy behavior.
File Description
tests/​examples/​test_swe_smith_tools.py Adds mocked regression coverage for tools, thinking, and compatibility.
examples/​swe_smith/​job-template-openai.yaml Adds disabled-by-default tool and thinking settings.
examples/​swe_smith/​agents/​smith_agent.py Implements native tool handling and reasoning-aware conversation history.
docs/​76-example-coding-agent-moe.md Links native tool and thinking setup for the MoE example.
docs/​75-example-coding-agent.md Documents rollout settings, parser overrides, and deployment updates.

Review effort: Balanced

else:
action = parse_action(
message.get("content") or "",
enable_thinking=enable_thinking and "reasoning_content" not in message,

This branch has not been deployed

No deployments
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.

2 participants