fix: resolve artifact refs in flattened multi-image items#51
Merged
Conversation
…items
`_flatten_grouped_image_items` produces a flat list whose elements can
still be artifact refs (``{"path": ...}`` shapes) when the upstream
result expression returned grouped lists. The downstream image-fetch
loop expects either a PIL image or a URL/path string and raises when
it sees a dict, so multi-image rows fail with an opaque validation
error.
Hoist the upstream context/root-node bindings out of the ``expr``
branch and re-run ``maybe_resolve_artifact_ref`` over the flattened
items before the fetch loop. When ``items`` came from a literal list
the bindings stay ``None`` and ``maybe_resolve_artifact_ref`` is a
no-op, so non-vision callers are unaffected.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Zhengyuan Su <su.zhengyuan@u.nus.edu>
Signed-off-by: Zhengyuan Su <su.zhengyuan@u.nus.edu>
kaiitunnz
reviewed
May 16, 2026
Collaborator
kaiitunnz
left a comment
There was a problem hiding this comment.
Overall looks good. I only have a small question.
| if fetch_images: | ||
| items, image_group_sizes = self._flatten_grouped_image_items(items) | ||
| items = [ | ||
| maybe_resolve_artifact_ref(item, context, root_node) |
Collaborator
There was a problem hiding this comment.
If we call maybe_resolve_artifact_ref here, is the call on line 422 still needed?
Collaborator
There was a problem hiding this comment.
Do you also need to add maybe_resolve_artifact_ref online 508?
The post-flatten resolution added in cbac9cb covers both cases: non-grouped items (where _flatten_grouped_image_items is a no-op) and grouped items. The earlier in-place resolution inside the `if expr` branch is therefore a duplicate. Drop it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Zhengyuan Su <su.zhengyuan@u.nus.edu>
Mirrors the post-flatten resolution in the fetch_images branch: when the non-image else branch consumes items via normalize_prompt_payload, items pulled through `expr` can still be artifact refs and need to be resolved first. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Zhengyuan Su <su.zhengyuan@u.nus.edu>
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.
Purpose
Fix multi-image vision inputs when grouped upstream artifact refs are flattened before image loading.
Changes
src/worker/executors/mixins/data.py— re-resolve flattened{path: ...}image artifact refs before fetching images.tests/worker/test_data_mixin_lineage.py— add a regression test for grouped image artifact refs from an upstream expression.Design
Keep the existing image fetch path unchanged. The fix only converts flattened artifact refs into the local path or URL shape that path already expects.
Test Plan
uv run pytest tests/worker/test_data_mixin_lineage.pyuv run ruff check tests/worker/test_data_mixin_lineage.pyuv run mypy tests/worker/test_data_mixin_lineage.pyTest Result
All targeted checks passed. Pre-commit hooks also passed when committing.
Pre-submission Checklist
pre-commit run --all-filesand fixed any issues.uv run pytest tests/passes locally.uv sync --all-packages --group ci --frozen).[BREAKING]and described migration steps above.