fix(agents): recover reasoning-only vLLM OpenAI-compat replies#31746
fix(agents): recover reasoning-only vLLM OpenAI-compat replies#31746liuxiaopai-ai wants to merge 1 commit intoopenclaw:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c2b73ac42
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const fallbackThinkingText = | ||
| !extracted && shouldFallbackToThinkingText(msg) | ||
| ? stripThinkingTagsFromText(extractAssistantThinking(msg)).trim() | ||
| : ""; | ||
| const textForUser = extracted || fallbackThinkingText; |
There was a problem hiding this comment.
Skip thinking fallback when reasoning output is enabled
The new fallback returns extractAssistantThinking(msg) as user text whenever text blocks are empty, but in the message-end flow we also independently emit reasoning from the same thinking blocks (extractAssistantThinking → formatReasoningMessage in src/agents/pi-embedded-subscribe.handlers.messages.ts). For non-OpenAI openai-completions sessions with reasoningMode: "on" and block replies enabled, a thinking-only assistant turn now produces duplicate output (once as normal answer text and once as a reasoning message), which is a regression from the previous behavior where only reasoning was emitted.
Useful? React with 👍 / 👎.
Greptile SummaryFixes empty assistant responses for non-OpenAI Key changes:
Test coverage:
The implementation is well-gated with defensive checks for edge cases (case-insensitive provider comparison, non-string provider values, multiple thinking blocks). Minor caveat: no live vLLM endpoint verification, relying on unit test coverage. Confidence Score: 4/5
Last reviewed commit: 0c2b73a |
Summary
Describe the problem and fix in 2–5 bullets:
openai-completionsproviders (reported with vLLM + DeepSeek) can return assistant turns where user-visiblecontentis empty while reasoning is present, resulting in empty OpenClaw replies.extractAssistantTextto recover text from reasoning blocks only for non-OpenAI providers onopenai-completions, and only when the turn is not a tool-call/error turn.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
message:sentinternal hook never fires for agent replies (all channels) #31293User-visible / Behavior Changes
api: openai-completions(for example vLLM), reasoning-only assistant responses no longer get dropped as empty text in the normal reply path.Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
openai-completions+ provider gatingmodels.providers.vllm.api = "openai-completions"Steps
extractAssistantText.provider=vllmvsprovider=openaiand for tool-call turns.Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
pnpm test src/agents/pi-embedded-utils.test.tspnpm test src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.subscribeembeddedpisession.test.tspnpm checkCompatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
fix(agents): recover reasoning-only openai-compat replies.src/agents/pi-embedded-utils.ts.Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.openai-completionsAPI, no tool calls, non-error turn) and covered by regression tests.