#accessing reasoning tokens
1 messages · Page 1 of 1 (latest)
This solution has been AI generated
It’s not currently possible to stream or access reasoning tokens in CopilotKit. The runtime and useCopilotChatHeadless_c only stream message content and tool calls; they don’t expose reasoning_tokens or similar usage fields from providers like OpenAI.
Current Status
- Not supported: CopilotKit’s OpenAI adapter streams text and tool-call chunks, but does not capture or return reasoning token usage or final usage stats.
- No runtime API: There are no stream completion callbacks or fields exposing
reasoning_tokensin the runtime. - Hook scope:
useCopilotChatHeadless_cprovides standard chat primitives (messages, sendMessage, isLoading, suggestions) without reasoning-token access.
What’s Available Instead
const {
messages,
sendMessage,
isLoading,
generateSuggestions,
interrupt,
} = useCopilotChatHeadless_c();
- Streams content and tool calls.
- No reasoning token metrics in the returned data.
Workarounds
- Direct provider integration: Call your LLM provider directly (e.g., non-streaming completion) to read final usage fields, including reasoning tokens, alongside CopilotKit.
- Custom runtime changes: Extend CopilotKit’s OpenAI adapter to capture and emit final usage stats once the stream completes.
- Contribution/feature request: This capability isn’t present in the codebase; adding it would require framework changes.
References
- Hook docs: https://docs.copilotkit.ai/reference/hooks/useCopilotChatHeadless_c
- Runtime OpenAI adapter (for streaming behavior): packages/runtime/src/service-adapters/openai/openai-adapter.ts
Was this helpful?
If this solution worked for you, please click on the appropriate option below to help us improve:
Thank you for your feedback! Our team will provide additional assistance. 🔄
Hi <@&1229452952104603650> I assume this is on the roadmap – can you give me a rough ETA so our team can decide on direct LLM integration or not
Hey! I've shared this with the team - they'll check and get back to you. Thanks!
It is about 2 weeks away I'd say @weak summit
@ivory dune thanks for the update – that timing works brilliantly.
+1 on the request!! super excited for CPK 1.5 Version
@wispy herald That's awesome to hear! Hope you've already signed up for the waitlist! If not, you can register here: https://www.copilotkit.ai/v150
yess I did!
Nice!! Thanks for signing up.
@gusty hamlet can you provide a brief overview of what to expect with v1.50? I also signup and looking forward to exploring the new updates.
@open wing Could you please answer this? Thanks!
Hey @austere axle, I can share a quick update on what’s actually coming in CopilotKit v1.50, and what's changing under the hood.
So yes - v1.50 is fully built on AG-UI now. What this means is that the frontend is speaking directly to agents through the AG-UI protocol instead of our older runtime bridge. It’s a big architectural shift, and it unlocks a lot of flexibility going forward.
A few specifics worth calling out:
- Thread support now works across frameworks. You can keep the conversation state whether you’re in Next.js, React, etc.
- You can reconnect to running agents. Drop your session, come back later, and pick up right where you left off.
- The entire AG-UI client API is exposed on the frontend now — things like subscribing to events, connecting to live agents, and even running agents outside of the chat flow.
- You can run multiple agents at once in the same UI.
For full customization, you can now subscribe to all AG-UI events and define your own behavior for how agents interact with your app.
Docs are here if you want to dig into what’s new on the client side:
👉 https://docs.ag-ui.com/sdk/js/client/subscriber
Also, sign up for the early access (we'll notify you once the prelease is out) at https://copilotkit.ai
Can’t wait to try v1.50
Can we still use direct LLMs?
Wanted to use ai-ask models in the past but it was not supported
Awesome, thank you Nathan! Looking forward to trying it out. Already signed up.
@sacred turtle FYI
Thanks @austere axle
Just an update here, we were hoping to ship the pre-release today but it's looking more like Monday. I will keep everyone posted!
@short dew, yes you can still use direct LLMs
1.50.0 is out for everyone following this thread!
@ivory dune where can I find the docs to access reasoning tokens?
Hi @wispy herald, currently there are not any. However, for your agent of choice you can emit ActivityEvents that will populate in the UI and be accessible via useAgent subscribers.
React hook for accessing AG-UI agent instances