Skip to content

fix(adapters): handle non-stream content with reasoning for responses#2885

Open
xhebox wants to merge 1 commit intoolimorris:mainfrom
xhebox:main
Open

fix(adapters): handle non-stream content with reasoning for responses#2885
xhebox wants to merge 1 commit intoolimorris:mainfrom
xhebox:main

Conversation

@xhebox
Copy link
Copy Markdown
Contributor

@xhebox xhebox commented Mar 12, 2026

format

Description

Output text is not necessarily the first block. Deepseek-reasoner met this.

AI Usage

Related Issue(s)

Screenshots

Checklist

  • I've read the contributing guidelines and have adhered to them in this PR
  • I confirm that this PR has been majority created by me, and not AI (unless stated in the "AI Usage" section above)
  • I've run make all to ensure docs are generated, tests pass and StyLua has formatted the code
  • (optional) I've added test coverage for this fix/feature
  • (optional) I've updated the README and/or relevant docs pages

format

Signed-off-by: xhe <xw897002528@gmail.com>
@olimorris
Copy link
Copy Markdown
Owner

Can you share what model you've encountered this with? The PR description is lacking detail.

@xhebox
Copy link
Copy Markdown
Contributor Author

xhebox commented Mar 12, 2026

Can you share what model you've encountered this with? The PR description is lacking detail.

Deepseek behind an LLM gateway called axonhub. But I think it is general, the fake test case is exactly same as the deepseek api. However it did not test the content at all.

EDIT: openai has the similar example too, https://developers.openai.com/api/docs/guides/migrate-to-responses. I met the problem when I use /compact, which is non-streaming.

h.expect_contains("**Choosing descriptive terms**", output.reasoning.content)
h.eq("rs_0a10a8c968d594670168e91d0204ac8195b26b3e4de997f65c", output.reasoning.id)
h.eq("gAAAAABo6", output.reasoning.encrypted_content)
h.eq("Dynamic expressive", output.content)
Copy link
Copy Markdown
Contributor Author

@xhebox xhebox Mar 13, 2026

Choose a reason for hiding this comment

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

FYI, sample data is not fully tested. Before the change, output.content is nil, while it is "Dynamic expressive" actually. The first block can be item.type == reasoning.

@olimorris

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I have no idea what you mean by "not fully tested".

I haven't tried this PR out yet but will run it through OpenAI's models at some point this weekend.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have no idea what you mean by "not fully tested".

mock data tests/adapters/http/stubs/openai_responses_inline.txt") has two items, type = reasoning for the first, type = message for the second.
We tested the reasoning content but not the message content in this test. It would not pass if we do check the message content.

@olimorris
Copy link
Copy Markdown
Owner

Sorry for not coming back to this sooner. Can you give me a set of steps to test this?

@xhebox
Copy link
Copy Markdown
Contributor Author

xhebox commented Mar 31, 2026

Sorry for not coming back to this sooner. Can you give me a set of steps to test this?

open a chat buffer with reasoning-enabled model(like deepseek-reasoner), make some random chats, then /compact.

Bug will be trigerred if the response has both reasoning and normal text content.

@xhebox
Copy link
Copy Markdown
Contributor Author

xhebox commented Apr 9, 2026

Any news? I've tested it on a lot of other APIs like nvidia or GLM.

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