Skip to content

fix(langfuse): Send structured input for traces - #1307

Closed
vprashrex wants to merge 3 commits into
feat/1294-telemetry-key-constantsfrom
feat/1048-langfuse-llm-input
Closed

vprashrex wants to merge 3 commits into
feat/1294-telemetry-key-constantsfrom
feat/1048-langfuse-llm-input

Conversation

@vprashrex

@vprashrex vprashrex commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Summary

  • Before: LLM call traces showed the input as a Python repr string.
  • Now: LLM call traces display structured JSON for inputs.
  • Added extract_query_input() to support structured JSON for LLM call traces.
  • Modified handling of various input types to display appropriate attributes.

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

Langfuse only; nothing changes in Sentry.

Original PR description

Issue

Related to #1048

Summary

LLM call traces in Langfuse showed the input as a Python repr string (type='text' content=TextContent(format='text', value='...', language_code=None)), unlike evaluation traces which show structured JSON.

  • Added extract_query_input() next to extract_response_output() in core/langfuse/langfuse.py, used for the unified-llm-call trace, its attributes and the generation.
  • Text input now shows type, content, format and language_code.
  • Audio, image and PDF inputs send only format, mime_type and length, never the base64 or URL payload, the same way audio output is already handled.
  • Multi-part inputs (a list) show each part.

Checklist

  • Ran fastapi run --reload app/main.py or docker compose up in the repository root and test.
  • If you've fixed a bug or added code that is tested and has test cases.

Notes

Langfuse only; nothing changes in Sentry.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 1
  • ready-for-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot changed the title fix(langfuse): Send structured input on LLM call traces fix(langfuse): Send structured input for traces Oct 24, 2026
@vprashrex
vprashrex marked this pull request as draft October 24, 2026 08:31
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

OpenAPI changes   ⚪ No API surface changes

Note

This PR does not modify the API contract.

main ↔ c3b88b83 · generated by oasdiff

@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 51.07914% with 68 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/app/core/langfuse/langfuse.py 30.20% 67 Missing ⚠️
backend/app/core/telemetry/llm.py 87.50% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

The unified-llm-call trace and generation passed the Pydantic query input
straight to Langfuse, which rendered its repr string. Add
extract_query_input to send type, content, format and language_code for
text, and metadata only (format, mime type, length) for audio, image and
PDF, mirroring extract_response_output.
…ry keys

- Trace metadata carries job.id, llm.call_id, llm.config.id/version, tenant ids,
  gen_ai.provider.name and gen_ai.request.model, the same keys as the Sentry spans
  (_CallContext.identity_attributes is the single source).
- Generation metadata adds llm.input/output type, format and language code, and
  gen_ai.response.id.
- billable_output_tokens is the one reasoning-token rule for Sentry and Langfuse.
- LLM_* keys and GEN_AI_RESPONSE_ID move to telemetry constants.
@vprashrex
vprashrex force-pushed the feat/1048-langfuse-llm-input branch from cf721e7 to 61a49e3 Compare October 24, 2026 14:20
@vprashrex
vprashrex changed the base branch from main to feat/1294-telemetry-key-constants October 24, 2026 14:20
@vprashrex vprashrex closed this Oct 24, 2026
@vprashrex vprashrex reopened this Oct 25, 2026
@vprashrex
vprashrex changed the base branch from feat/1294-telemetry-key-constants to main October 25, 2026 04:53
@vprashrex
vprashrex changed the base branch from main to feat/1294-telemetry-key-constants October 25, 2026 04:53
@vprashrex vprashrex closed this Oct 25, 2026
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.

1 participant