Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep provider reasoning out of visible answers

rcourtmanc25629ddf022
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index d4bc0b56e3..77bc2fe5b9 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -459,6 +459,22 @@ runtime cost control, and shared AI transport surfaces.
showing a live `Thinking:`/completed `Thought:` row with duration and optional
provider summary title while keeping the raw reasoning body out of the
transcript.
+ Provider reasoning must not become fallback assistant answer text when an
+ OpenAI-compatible non-stream response contains `reasoning` or
+ `reasoning_content` without visible `content`. The referenced OpenCode
+ source at fetched `origin/dev` commit
+ `4519a1da329c1a4fc384054e7203ba7d06928205` maps AI SDK
+ `reasoning-start` / `reasoning-delta` / `reasoning-end` events to
+ dedicated reasoning events in
+ `packages/opencode/src/session/llm/ai-sdk.ts` (lines 158-188), preserves
+ assistant reasoning as a `type: "reasoning"` message part in
+ `packages/opencode/src/session/message-v2.ts` (lines 374-387), and keeps
+ text and reasoning renderability distinct in
+ `packages/ui/src/components/message-part.tsx` (lines 607-615). Pulse adapts
+ that boundary by keeping `ChatResponse.Content` limited to provider
+ `message.content` and storing OpenAI-compatible reasoning only in
+ `ReasoningContent`, so hidden provider reasoning cannot be rendered as the
+ final answer by any Pulse surface that consumes non-stream chat responses.
The active-turn status strip follows the same source-backed part freshness
rule: OpenCode commit `9ed17da55ab1f7360cc0e01075f763e27fa899e9`
updates live assistant parts in place through
diff --git a/internal/ai/providers/openai.go b/internal/ai/providers/openai.go
index 8722dba637..a086a6aa8f 100644
--- a/internal/ai/providers/openai.go
+++ b/internal/ai/providers/openai.go
@@ -544,15 +544,8 @@ func (c *OpenAIClient) Chat(ctx context.Context, req ChatRequest) (*ChatResponse
reasoning = choice.Message.Reasoning
}
- // When a reasoner returns no visible content, fall back to the reasoning text
- // so the turn still carries the model's output instead of an empty string.
- contentToUse := choice.Message.Content
- if contentToUse == "" && reasoning != "" {
- contentToUse = reasoning
- }
-
result := &ChatResponse{
- Content: contentToUse,
+ Content: choice.Message.Content,
ReasoningContent: reasoning, // surfaced as the turn's thinking
Model: openaiResp.Model,
StopReason: choice.FinishReason,
diff --git a/internal/ai/providers/openai_test.go b/internal/ai/providers/openai_test.go
index eb0eab00bf..bdd4aadeb3 100644
--- a/internal/ai/providers/openai_test.go
+++ b/internal/ai/providers/openai_test.go
@@ -395,6 +395,29 @@ func TestOpenAIClient_Chat_OpenRouterDefaultsCompletionBudget(t *testing.T) {
assert.Zero(t, captured.MaxTokens)
}
+func TestOpenAIClient_Chat_KeepsReasoningOutOfVisibleContent(t *testing.T) {
+ client := NewOpenAIClient("sk-test", "openrouter:deepseek/deepseek-v4-pro", "https://openrouter.ai/api/v1", 0)
+ client.client = &http.Client{
+ Transport: roundTripFunc(func(r *http.Request) (*http.Response, error) {
+ return &http.Response{
+ StatusCode: http.StatusOK,
+ Header: http.Header{"Content-Type": []string{"application/json"}},
+ Body: io.NopCloser(strings.NewReader(
+ `{"id":"chatcmpl-1","model":"deepseek/deepseek-v4-pro","choices":[{"message":{"role":"assistant","reasoning":"We need to inspect the prompt before answering."},"finish_reason":"stop"}]}`,
+ )),
+ }, nil
+ }),
+ }
+
+ resp, err := client.Chat(context.Background(), ChatRequest{
+ Messages: []Message{{Role: "user", Content: "Hi"}},
+ })
+
+ require.NoError(t, err)
+ assert.Empty(t, resp.Content)
+ assert.Equal(t, "We need to inspect the prompt before answering.", resp.ReasoningContent)
+}
+
func TestOpenAIClient_ChatStream_ToolCall(t *testing.T) {
// Mock tool call stream
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {