Skip to content

fix(telemetry): restore userId and sessionId metadata in experimental_telemetry#8195

Merged
rekram1-node merged 1 commit intoanomalyco:devfrom
Raviguntakala:feature/telemetry-userid-sessionid
Jan 29, 2026
Merged

fix(telemetry): restore userId and sessionId metadata in experimental_telemetry#8195
rekram1-node merged 1 commit intoanomalyco:devfrom
Raviguntakala:feature/telemetry-userid-sessionid

Conversation

@Raviguntakala
Copy link
Contributor

What does this PR do?

Fixes #8193

Restores userId and sessionId metadata to experimental_telemetry in llm.ts, which was removed during LLM refactoring.

Originally added in #5279.

How did you verify your code works?

Tested with Langfuse - traces correctly group by session and display user attribution.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@nonepage
Copy link

Wow, he's very useful. Some models' cache hits also depend on this. Why hasn't anyone merged them😂

@Raviguntakala
Copy link
Contributor Author

Hey @rekram1-node , can you take a quick look at this PR when you have time? Simple regression fix.

@SXGC
Copy link

SXGC commented Jan 23, 2026

This would be a great addition to the experimental telemetry. Hoping to see this merged soon!

@SimonLiu423
Copy link

I'm experiencing the same issue from #8193 and would benefit from this fix.

@tisoz
Copy link

tisoz commented Jan 29, 2026

please merged , i also need this

@tisoz
Copy link

tisoz commented Jan 29, 2026

What does this PR do?

Fixes #8193修复内容 #8193

Restores userId and sessionId metadata to experimental_telemetry in llm.ts, which was removed during LLM refactoring.恢复在 llm.ts 中 userIdsessionId 元数据到 experimental_telemetry,这些数据在 LLM 重构期间被移除。

Originally added in #5279.  最初在 #5279 中添加。

How did you verify your code works?

Tested with Langfuse - traces correctly group by session and display user attribution.使用 Langfuse 进行测试 - 跟踪记录能够正确按会话分组并显示用户归属。

hi bro , can i got your help , i tried modify in source code .
but the code is not work .

do you have any idea

this is log :

INFO  2026-01-29T11:31:52 +2ms service=llm providerID=anthropic modelID=claude-haiku-4-5 sessionID=ses_3f679d82cffeN5IVnupdZJDlYU small=true agent=title mode=primary experimental_telemetry={"isEnabled":true,"metadata":{"userId":"tisoz","sessionId":"ses_3f679d82cffeN5IVnupdZJDlYU"}} tisoz_test2
ERROR 2026-01-29T11:31:53 +287ms service=llm providerID=anthropic modelID=claude-haiku-4-5 sessionID=ses_3f679d82cffeN5IVnupdZJDlYU small=true agent=title mode=primary error={"error":{"name":"AI_APICallError","url":"https://code.newcli.com/claude/aws/v1/messages","requestBodyValues":{"model":"claude-haiku-4-5","max_tokens":32000,"temperature":0.5,"system":[{"type":"text","text":"You are Claude Code, Anthropic's official CLI for Claude.","cache_control":{"type":"ephemeral"}},{"type":"text","text":"You are Claude Code, Anthropic's official CLI for Claude.\n\nYou are a title generator. You output ONLY a thread title. Nothing else.\r\n\r\n<task>\r\nGenerate a brief title that would help the user find this conversation later.\r\n\r\nFollow all rules in <rules>\r\nUse the <examples> so you know what a good title looks like.\r\nYour output must be:\r\n- A single line\r\n- ≤50 characters\r\n- No explanations\r\n</task>\r\n\r\n<rules>\r\n- you MUST use the same language as the user message you are summarizing\r\n- Title must be grammatically correct and read naturally - no word salad\r\n- Never include tool names in the title (e.g. \"read tool\", \"bash tool\", \"edit tool\")\r\n- Focus on the main topic or question the user needs to retrieve\r\n- Vary your phrasing - avoid repetitive patterns like always starting with \"Analyzing\"\r\n- When a file is mentioned, focus on WHAT the user wants to do WITH the file, not just that they shared it\r\n- Keep exact: technical terms, numbers, filenames, HTTP codes\r\n- Remove: the, this, my, a, an\r\n- Never assume tech stack\r\n- Never use tools\r\n- NEVER respond to questions, just generate a title for the conversation\r\n- The title should NEVER include \"summarizing\" or \"generating\" when generating a title\r\n- DO NOT SAY YOU CANNOT GENERATE A TITLE OR COMPLAIN ABOUT THE INPUT\r\n- Always output something meaningful, even if the input is minimal.\r\n- If the user message is short or conversational (e.g. \"hello\", \"lol\", \"what's up\", \"hey\"):\r\n  → create a title that reflects the user's tone or intent (such as Greeting, Quick check-in, Light chat, Intro message, etc.)\r\n</rules>\r\n\r\n<examples>\r\n\"debug 500 errors in production\" → Debugging production 500 errors\r\n\"refactor user service\" → Refactoring user service\r\n\"why is app.js failing\" → app.js failure investigation\r\n\"implement rate limiting\" → Rate limiting implementation\r\n\"how do I connect postgres to my API\" → Postgres API connection\r\n\"best practices for React hooks\" → React hooks best practices\r\n\"@src/auth.ts can you add refresh token support\" → Auth refresh token support\r\n\"@utils/parser.ts this is broken\" → Parser bug fix\r\n\"look at @config.json\" → Config review\r\n\"@App.tsx add dark mode toggle\" → Dark mode toggle in App\r\n</examples>\r\n","cache_control":{"type":"ephemeral"}}],"messages":[{"role":"user","content":[{"type":"text","text":"Generate a title for this conversation:\n","cache_control":{"type":"ephemeral"}},{"type":"text","text":"hi","cache_control":{"type":"ephemeral"}}]}],"stream":true},"statusCode":400,"responseHeaders":{"cf-cache-status":"DYNAMIC","cf-ray":"9c5867df390ee9df-LAX","connection":"keep-alive","content-length":"138","content-type":"text/plain; charset=utf-8","date":"Thu, 29 Jan 2026 11:31:53 GMT","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=68aaYRodj07P9ql4CGzuYxsX8ZA2k8li3w69OnuwEClMtoPP01bogeHOWBeaO%2FTNVbbKUc9C5fWSHjN5zHJvq3ycQBy1vnMShQ0KfuWS\"}]}","server":"cloudflare","x-content-type-options":"nosniff"},"responseBody":"{\"error\":{\"code\":\"model_not_found\",\"message\":\"模型 claude-haiku-4-5 未开放,可通过/model切换到sonnet4.5模型\",\"type\":\"404\"}}\n","isRetryable":false}} stream error

i noticed the request body not take metadata params

@Raviguntakala
Copy link
Contributor Author

@tisoz The Vercel AI SDK doesn't send any metadata values present experimental_telemetry to LLM provider APIs. The experimental_telemetry parameter is only used for telemetry purposes - these values are NOT sent to the LLM request body

@rekram1-node rekram1-node merged commit 03ba49a into anomalyco:dev Jan 29, 2026
4 checks passed
@tisoz
Copy link

tisoz commented Jan 29, 2026

@tisoz The Vercel AI SDK doesn't send any metadata values present experimental_telemetry to LLM provider APIs. The experimental_telemetry parameter is only used for telemetry purposes - these values are NOT sent to the LLM request bodyVercel AI SDK 不会向 LLM 提供商 API 发送任何包含 experimental_telemetry 的元数据值。experimental_telemetry 参数仅用于遥测目的——这些值不会被发送到 LLM 请求体中。

thanks bro , some proviver use metadata to enabled cache fetures.

maybe i need found a custom the way . looks not good :(

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.

experimental_telemetry metadata removed during LLM refactor

6 participants