Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -562,4 +562,7 @@ Think of this as the reverse-task assignment - a place where you can communicate
- [ ] Repair the existing `pnpm run typecheck:examples` failures caused by
OpenAI type drift in `examples/agent.ts`, `classesWithOps.ts`,
`imageGeneration.ts`, `quickstart*.ts`, and `streamFunctionCalls.ts`.
- [ ] Exclude `.git` from the Ruff pre-push scan. A remote branch whose name
Comment thread
rgao-coreweave marked this conversation as resolved.
Outdated
ends in `.py` currently makes `nox --no-install -e lint` parse its ref and
reflog files as Python source.
- [ ] ...
34 changes: 34 additions & 0 deletions tests/trace_server/test_genai_chat_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,40 @@ def test_inline_internal_ref_surfaces_without_span_content_refs() -> None:
assert _assistant_payload(assistant).content_refs == []


def test_blob_content_is_media_not_user_message_text() -> None:
"""A Weave blob's `content` is base64/ref data, not displayable prose."""
image_internal = "weave-trace-internal:///PID/object/Content:IMAGEDIGEST"
spans = [
_span(
span_id="agent",
operation_name="invoke_agent",
agent_name="image-analyzer",
input_messages=[
{
"role": "user",
"content": _parts(
{
"type": "blob",
"content": image_internal,
"mimeType": "image/png",
"modality": "image",
},
_text_part("Describe this image."),
),
}
],
)
]

messages = build_chat_messages(spans)
user = next(m for m in messages if m.type == "user_message")

assert _user_payload(user) == AgentChatUserMessage(
text="Describe this image.",
content_refs=[image_internal],
)


@pytest.mark.xfail(
reason=(
"Known limitation (PR #7489 discussion): the inline-ref sweep "
Expand Down
7 changes: 6 additions & 1 deletion weave/trace_server/agents/chat_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,9 +709,14 @@ def _display_text(content: str) -> str:
# concatenating it here would duplicate it in the message body.
if p.get("type") == "reasoning":
continue
# Weave blob parts carry their base64 payload (or the Content ref
# that replaces it at ingest) in `content`. That field is media,
# not prose, and must not leak into the chat bubble's text.
if p.get("type") in _MEDIA_PART_TYPES:
continue
# Support both the weave parts model (``content``) and the
# OpenAI-style multimodal shape (``text``). Non-text parts (e.g.
# images) carry neither and are skipped for display.
# images) are skipped for display.
if isinstance(p.get("content"), str):
texts.append(p["content"])
elif isinstance(p.get("text"), str):
Expand Down
Loading