From 737c3a75b435c0cc1cdfc15ce85c5b7d7bf86a97 Mon Sep 17 00:00:00 2001 From: Ramnique Singh <30795890+ramnique@users.noreply.github.com> Date: Wed, 18 Feb 2026 22:07:54 +0530 Subject: [PATCH] send reasoning blocks back to llm --- apps/x/packages/core/src/agents/runtime.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/x/packages/core/src/agents/runtime.ts b/apps/x/packages/core/src/agents/runtime.ts index 8b1bd54e..4150d958 100644 --- a/apps/x/packages/core/src/agents/runtime.ts +++ b/apps/x/packages/core/src/agents/runtime.ts @@ -226,13 +226,14 @@ export class StreamStepMessageBuilder { private textBuffer: string = ""; private reasoningBuffer: string = ""; private providerOptions: z.infer | undefined = undefined; + private reasoningProviderOptions: z.infer | undefined = undefined; flushBuffers() { - // skip reasoning - // if (this.reasoningBuffer) { - // this.parts.push({ type: "reasoning", text: this.reasoningBuffer }); - // this.reasoningBuffer = ""; - // } + if (this.reasoningBuffer || this.reasoningProviderOptions) { + this.parts.push({ type: "reasoning", text: this.reasoningBuffer, providerOptions: this.reasoningProviderOptions }); + this.reasoningBuffer = ""; + this.reasoningProviderOptions = undefined; + } if (this.textBuffer) { this.parts.push({ type: "text", text: this.textBuffer }); this.textBuffer = ""; @@ -242,7 +243,11 @@ export class StreamStepMessageBuilder { ingest(event: z.infer) { switch (event.type) { case "reasoning-start": + break; case "reasoning-end": + this.reasoningProviderOptions = event.providerOptions; + this.flushBuffers(); + break; case "text-start": case "text-end": this.flushBuffers();