Implement Langfuse Media Token attachment for inline UI rendering#69
Conversation
…nd comments Co-authored-by: jgwill <23141173+jgwill@users.noreply.github.com>
Co-authored-by: jgwill <23141173+jgwill@users.noreply.github.com>
Co-authored-by: jgwill <23141173+jgwill@users.noreply.github.com>
…ofing Co-authored-by: jgwill <23141173+jgwill@users.noreply.github.com>
Co-authored-by: jgwill <23141173+jgwill@users.noreply.github.com>
|
During testing of the Details:
Diagnosis: Recommendation for Implementation Agent:
For future testing, a small, non-empty |
Propagate error details from underlying upload_and_attach_media function to provide better debugging information when media uploads fail.
…us updates (#68) - Changed SHA256 hashing from hexdigest to base64 encoding (44-char format required by Langfuse) - Accept both 200 and 201 status codes as success in media upload URL requests - Add SHA256 checksum header to S3 uploads for integrity validation - Handle media deduplication: skip upload if file already exists (uploadUrl null) - Add uploadedAt timestamp to media patch status updates - Include detail field in error responses for better debugging - Properly handle existing media data when deduplication occurs
ad577a7
into
claude/langfuse-media-support-01DKbZAHAypsV2cbMgs2Joqf
The media upload implementation was uploading files to S3 but not attaching Langfuse Media Tokens to traces/observations, preventing inline rendering in the Langfuse UI.
Changes
Media Token System
create_langfuse_media_token()- generates standardized@@@langfuseMedia:type={MIME}|id={ID}|source={TYPE}@@@tokensattach_media_token_to_trace()- injects tokens into trace fields via ingestion APIattach_media_token_to_observation()- injects tokens into observation fieldsupload_and_attach_media()to automatically generate and attach tokens after S3 uploadSecurity Hardening
malicious-amazonaws.com)bucket.s3.amazonaws.com)Code Quality
timeandurlparseimports to module levelexceptwith specific exception types and explanatory commentsosimportDocumentation
MEDIA_UPLOAD_GUIDE.mdwith CLI/API/MCP examples and troubleshootingExample Usage
# CLI automatically handles token attachment coaia fuse media upload photo.jpg trace_abc123 --field outputToken Format
Per Langfuse spec:
@@@langfuseMedia:type={MIME_TYPE}|id={MEDIA_ID}|source={SOURCE}@@@Tokens are injected via trace/observation PATCH operations using the ingestion API's event merging mechanism.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.