6ede33ccdb
Build and Push Docker Images / create_manifest (web, surfsense-web, , cpu) (push) Has been cancelled
Build and Push Docker Images / finalize_release (push) Has been cancelled
Obsidian Plugin Lint / lint (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64, , runner, false, cpu) (push) Has been cancelled
Build and Push Docker Images / compute_version (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, , production, false, cpu) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda126, production, true, cuda126) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda, production, true, cuda) (push) Has been cancelled
Build and Push Docker Images / verify_digests (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, , cpu) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda, cuda) (push) Has been cancelled
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda126, cuda126) (push) Has been cancelled
80 lines
2.2 KiB
Python
80 lines
2.2 KiB
Python
"""Pin the wire compactness rule and the top-level ``emitted_by`` field name."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from app.services.streaming.emitter import (
|
|
Emitter,
|
|
attach_emitted_by,
|
|
main_emitter,
|
|
subagent_emitter,
|
|
)
|
|
|
|
pytestmark = pytest.mark.unit
|
|
|
|
|
|
def test_main_emitter_payload_contains_only_level() -> None:
|
|
payload = main_emitter().to_payload()
|
|
assert payload == {"level": "main"}
|
|
|
|
|
|
def test_subagent_emitter_payload_includes_all_set_fields() -> None:
|
|
payload = subagent_emitter(
|
|
subagent_type="deliverables",
|
|
subagent_run_id="subagent_abc",
|
|
parent_tool_call_id="call_xyz",
|
|
).to_payload()
|
|
assert payload == {
|
|
"level": "subagent",
|
|
"subagent_type": "deliverables",
|
|
"subagent_run_id": "subagent_abc",
|
|
"parent_tool_call_id": "call_xyz",
|
|
}
|
|
|
|
|
|
def test_subagent_emitter_payload_omits_unset_optional_fields() -> None:
|
|
"""parent_tool_call_id is None when the run is started outside a tool boundary."""
|
|
payload = Emitter(
|
|
level="subagent",
|
|
subagent_type="email",
|
|
subagent_run_id="subagent_1",
|
|
).to_payload()
|
|
assert "parent_tool_call_id" not in payload
|
|
assert payload["subagent_type"] == "email"
|
|
|
|
|
|
def test_extra_fields_merge_into_payload() -> None:
|
|
"""Future extension fields (e.g. lane colour, label) flow through ``extra``."""
|
|
emitter = subagent_emitter(
|
|
subagent_type="search",
|
|
subagent_run_id="r1",
|
|
extra={"label": "Web Search"},
|
|
)
|
|
assert emitter.to_payload()["label"] == "Web Search"
|
|
|
|
|
|
def test_attach_emitted_by_with_none_is_noop() -> None:
|
|
payload = {"type": "text-delta", "delta": "hi"}
|
|
result = attach_emitted_by(payload, None)
|
|
assert "emitted_by" not in result
|
|
assert result is payload
|
|
|
|
|
|
def test_attach_emitted_by_adds_payload_under_snake_case_top_level_key() -> None:
|
|
payload = {"type": "text-delta", "delta": "hi"}
|
|
attach_emitted_by(
|
|
payload,
|
|
subagent_emitter(
|
|
subagent_type="x",
|
|
subagent_run_id="y",
|
|
parent_tool_call_id="z",
|
|
),
|
|
)
|
|
assert payload["emitted_by"] == {
|
|
"level": "subagent",
|
|
"subagent_type": "x",
|
|
"subagent_run_id": "y",
|
|
"parent_tool_call_id": "z",
|
|
}
|