Repository navigation
perf(media): reuse downloads for repeated references within a call - #2022
Open
Apeksha9389 wants to merge 1 commit into
Open
Apeksha9389 wants to merge 1 commit into
Apeksha9389 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Reuse successful media resolutions within one
LangfuseMedia.resolve_media_references()call. Repeated image or audio references in multimodal inputs now share their metadata lookup and download, including across nested messages. A new call fetches fresh content, and failed resolutions remain retryable at later positions.The regression input has three copies of one reference. On main it makes three metadata requests and three downloads; with this change it makes one of each and produces the same resolved content. Additional tests cover distinct references, fetch failures, input preservation, call isolation and the traversal depth limit.
Type of change
Verification
.venv/bin/python -m pytest tests/unit/test_media.py tests/unit/test_json_path.py -q .venv/bin/ruff check . .venv/bin/ruff format --check langfuse/media.py tests/unit/test_media.py .venv/bin/mypy langfuse --no-error-summaryAll pass on macOS/Python 3.12.14; 48 tests pass. The repeated-reference regression was confirmed failing before the implementation. Dependencies were installed with
uv sync --locked; commands used the resulting.venvexecutables. Backend e2e and live-provider tests were not run because this change is covered by offline media-resolution tests.Checklist
code_review.md.AI disclosure: The change, tests and description were prepared with OpenAI Codex assistance. All reported checks were executed locally.


Confidence Score: 5/5
This PR appears safe to merge.Summary
LangfuseMedia.resolve_media_references()now reuses successful downloads within one call.Reviews (1) · Last reviewed commit: "perf(media): reuse successful resolution..." · Reviewed by Greptile