Files
ThothII/docs/research/2026-09-21-pi-qwen-compatibility.md
T
Codex 84084bba37
Publish documentation / publish (push) Successful in 30s
Fix Qwen session tool calls and expose thinking compatibility
2026-09-21 16:23:51 +02:00

3.3 KiB

Qwen 3.6: session tool-call failure and correction

Date: 2026-09-21. Verified runtime: Pi coding agent and Pi AI 0.80.3.

Cause and correction

Interactive sessions returned text resembling a bash call and stopped before the first review widget. The Evidence-only extension tht-evidence-json-mode.ts lived under .pi/extensions, so Pi automatically loaded it into interactive sessions. Its before_provider_request hook imposed response_format: {type: "json_object"} and temperature zero on every request.

Replaying the captured startup request, with all original hooks preserved, isolated the cause. With JSON response format, Qwen returned the command as text and finish reason stop. Removing only that field produced a native bash call and finish reason tool_calls. Both requests contained the same 15 tools and used High thinking.

The extension now lives in .pi/evidence-extensions and is loaded explicitly by PiEvidenceRestructurer. Evidence retains JSON output. Interactive sessions retain native tool calls. No changes to the remote Qwen server were required.

Earlier SDK probes replaced session.agent.onPayload, inadvertently bypassing the extension hooks. Their success did not reproduce the application path and did not establish a model or server fault.

Model configuration

The installation catalog now accepts optional session.compatibility.thinkingFormat values qwen and qwen-chat-template, requiring reasoning: true. Go validation, the backend schema, and generated catalog/Pi projections preserve this setting. It controls thinking; it was not the cause or correction of the tool-call failure.

For the verified endpoint, qwen-chat-template sends enable_thinking and preserve_thinking inside chat_template_kwargs. Selecting Off explicitly disables thinking. Declaring reasoning: false alone does not disable thinking on the server. See the operator configuration and Pi 0.80.3 model documentation.

Validation and local delivery

  • Catalog and projection regression tests failed before the compatibility change, then passed. Go config/modelprojection/CLI tests, 84 targeted backend tests, TypeScript checking, and the strict documentation build passed.
  • The extension-isolation regression failed before relocation. All 46 Evidence authoring/restructurer tests and Ruff checks on changed Python files passed.
  • The rebuilt local core image has digest sha256:9cd593d7362dcbefe177f1b9eb4b9ffdf3010ced7bd7efc8fc3fdcd288f24579. Core/frontend were recreated, healthy, and returned HTTP 200.
  • A real pi --mode rpc --no-session probe with Qwen and High thinking executed tht session show successfully and reached the first clarification widget. The probe allowed only that read and reviewer_select; it stopped without submitting a human response or recording decisions. Its temporary configuration referenced the mounted credential because the original runtime lease had expired.
  • The user subsequently confirmed that the application now works.

This verifies recovery from the startup failure. It does not certify every workflow phase or the separate LiteLLM metadata-generation path.