Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

Restore OpenCode reasoning replay for tool turns (#1328)

Ali Khokhara01c282ac683
diff --git a/pyproject.toml b/pyproject.toml
index 5bc5dd4a..f04584f7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "free-claude-code"
-version = "4.16.5"
+version = "4.16.6"
description = "Local proxy connecting coding agents to OpenAI-compatible AI providers"
readme = "README.md"
requires-python = ">=3.14.0"
diff --git a/src/free_claude_code/providers/openai_chat/profiles.py b/src/free_claude_code/providers/openai_chat/profiles.py
index 67e3de98..21dde3bc 100644
--- a/src/free_claude_code/providers/openai_chat/profiles.py
+++ b/src/free_claude_code/providers/openai_chat/profiles.py
@@ -157,11 +157,11 @@ OPENAI_CHAT_PROFILES: dict[str, OpenAIChatProfile] = {
NO_REASONING,
),
"opencode": OpenAIChatProfile(
- _policy("OPENCODE", ReasoningReplayMode.THINK_TAGS),
+ _policy("OPENCODE", ReasoningReplayMode.REASONING_CONTENT),
NO_REASONING,
),
"opencode_go": OpenAIChatProfile(
- _policy("OPENCODE_GO", ReasoningReplayMode.THINK_TAGS),
+ _policy("OPENCODE_GO", ReasoningReplayMode.REASONING_CONTENT),
NO_REASONING,
),
"vercel": OpenAIChatProfile(
diff --git a/tests/providers/test_opencode.py b/tests/providers/test_opencode.py
index 8d99d862..4eeb9553 100644
--- a/tests/providers/test_opencode.py
+++ b/tests/providers/test_opencode.py
@@ -1,5 +1,7 @@
"""Tests for the OpenCode OpenAI-compatible provider."""
+import pytest
+
from free_claude_code.core.anthropic.models import MessagesRequest
from free_claude_code.providers.base import ProviderConfig
from tests.providers.support import (
@@ -9,9 +11,12 @@ from tests.providers.support import (
)
-def test_build_request_body_omits_empty_reasoning_content() -> None:
[email protected]("provider_id", ["opencode", "opencode_go"])
+def test_build_request_body_preserves_empty_reasoning_content(
+ provider_id: str,
+) -> None:
provider = profiled_provider(
- "opencode",
+ provider_id,
ProviderConfig(
api_key="test_opencode_key",
base_url="https://example.invalid/v1",
@@ -39,4 +44,68 @@ def test_build_request_body_omits_empty_reasoning_content() -> None:
assert body["messages"][0] == {
"role": "assistant",
"content": "visible",
+ "reasoning_content": "",
+ }
+
+
[email protected]("provider_id", ["opencode", "opencode_go"])
+def test_build_request_body_replays_tool_reasoning_natively(
+ provider_id: str,
+) -> None:
+ provider = profiled_provider(
+ provider_id,
+ ProviderConfig(
+ api_key="test_opencode_key",
+ base_url="https://example.invalid/v1",
+ rate_limit=1,
+ rate_window=1,
+ ),
+ admission=immediate_admission(),
+ )
+ request = MessagesRequest.model_validate(
+ {
+ "model": "m",
+ "messages": [
+ {
+ "role": "assistant",
+ "content": [
+ {
+ "type": "thinking",
+ "thinking": "I should inspect the file.",
+ "signature": "sig",
+ },
+ {
+ "type": "tool_use",
+ "id": "call_1",
+ "name": "Read",
+ "input": {"path": "README.md"},
+ },
+ ],
+ },
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "tool_result",
+ "tool_use_id": "call_1",
+ "content": "file contents",
+ }
+ ],
+ },
+ ],
+ "thinking": {"type": "enabled"},
+ }
+ )
+
+ body = provider._build_request_body(request, reasoning=reasoning_for(request))
+
+ assistant = body["messages"][0]
+ assert assistant["content"] == ""
+ assert assistant["reasoning_content"] == "I should inspect the file."
+ assert "<think>" not in assistant["content"]
+ assert assistant["tool_calls"][0]["id"] == "call_1"
+ assert body["messages"][1] == {
+ "role": "tool",
+ "tool_call_id": "call_1",
+ "content": "file contents",
}
diff --git a/uv.lock b/uv.lock
index ff0f7c54..042bfc56 100644
--- a/uv.lock
+++ b/uv.lock
@@ -620,7 +620,7 @@ wheels = [
[[package]]
name = "free-claude-code"
-version = "4.16.5"
+version = "4.16.6"
source = { editable = "." }
dependencies = [
{ name = "aiohttp" },