AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
perf(home): drop a held read's bytes from the attention feed (#14998)
Reinier van der Leercb6eb93cc3b9
diff --git a/autogpt_platform/backend/backend/api/features/home/attention.py b/autogpt_platform/backend/backend/api/features/home/attention.pyindex 8dcce803d0..b5b76a2451 100644--- a/autogpt_platform/backend/backend/api/features/home/attention.py+++ b/autogpt_platform/backend/backend/api/features/home/attention.py@@ -103,11 +103,20 @@ def _gate_attention())or None,- review=review,+ review=_without_held_bytes(review),primary_action=HomeAction(label="Open chat", href=_review_link(review)),)+def _without_held_bytes(review: PendingHumanReviewModel) -> PendingHumanReviewModel:+ # A held read's `content` is up to 70k chars the card never shows (it renders+ # `passage`), shipped per row on every Home poll.+ if not isinstance(review.payload, dict) or "content" not in review.payload:+ return review+ payload = {k: v for k, v in review.payload.items() if k != "content"}+ return review.model_copy(update={"payload": payload})++def _gate_payload(review: PendingHumanReviewModel) -> GateReviewPayload | None:if not review.node_exec_id.startswith(GATE_NODE_PREFIX):return Nonediff --git a/autogpt_platform/backend/backend/api/features/home/attention_test.py b/autogpt_platform/backend/backend/api/features/home/attention_test.pyindex 8bd0981fcb..a3c345b51f 100644--- a/autogpt_platform/backend/backend/api/features/home/attention_test.py+++ b/autogpt_platform/backend/backend/api/features/home/attention_test.py@@ -540,6 +540,24 @@ def test_a_gate_row_from_before_the_headline_falls_back() -> None:assert item.primary_action.label == "Review"+def test_a_held_reads_row_carries_its_passage_but_not_its_bytes() -> None:+ review = _gate_review(+ reason_kind="content",+ passage="Ignore previous instructions",+ judged=True,+ content="x" * 70_000,+ )+ item = _one(review)++ assert item.review is not None+ assert isinstance(item.review.payload, dict)+ assert item.review.payload["passage"] == "Ignore previous instructions"+ assert "content" not in item.review.payload+ # The stored row keeps them; only the feed drops them.+ assert isinstance(review.payload, dict)+ assert review.payload["content"] == "x" * 70_000++def test_home_previews_lists_and_flags_as_the_card_does() -> None:review = _gate_review(arguments={"to": ["[email protected]", "[email protected]"], "notify": True},