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.
feat(platform/copilot): approval cards for bare tools offer "Approve from now on" and "Let Otto judge from now on" (#14980)
Reinier van der Leer524cae993ec5
diff --git a/autogpt_platform/backend/backend/api/features/graph_executions/review/review_routes_test.py b/autogpt_platform/backend/backend/api/features/graph_executions/review/review_routes_test.pyindex e3f3c354ac..dafef361e8 100644--- a/autogpt_platform/backend/backend/api/features/graph_executions/review/review_routes_test.py+++ b/autogpt_platform/backend/backend/api/features/graph_executions/review/review_routes_test.py@@ -1425,12 +1425,22 @@ async def test_an_answer_on_a_chat_card_wakes_that_chat(@pytest.mark.asyncio(loop_scope="session")@pytest.mark.parametrize("scope", ["chat", "expert", "team"])+ "tool, rule_key",+ [+ ("run_capability", "mcp:h/t"),+ # A bare tool's card rules on the tool itself.+ ("create_agent", "create_agent"),+ ],+)async def test_an_approved_chat_card_sets_the_rule_it_asked_for(client: httpx.AsyncClient,mocker: pytest_mock.MockerFixture,sample_pending_review: PendingHumanReviewModel,test_user_id: str,scope: str,+ tool: str,+ rule_key: str,) -> None:"""The rule lands on the subject the gate stored with the held call."""review = sample_pending_review.model_copy(@@ -1438,10 +1448,10 @@ async def test_an_approved_chat_card_sets_the_rule_it_asked_for()held_call = HeldCall(review_id="test_node_123",- tool_name="run_capability",+ tool_name=tool,tool_call_id="c",args={},- rule_key="mcp:h/t",+ rule_key=rule_key,)# The turn the answer wakes claims the held call, so it is gone afterwards.held_calls = {"test_node_123": held_call}@@ -1485,11 +1495,11 @@ async def test_an_approved_chat_card_sets_the_rule_it_asked_for()assert response.status_code == 200- set_rule.assert_awaited_once_with("s1", "mcp:h/t", "allow")+ set_rule.assert_awaited_once_with("s1", rule_key, "allow")if scope == "chat":set_scoped_rule.assert_not_called()else:expert = "frankie" if scope == "expert" else Noneset_scoped_rule.assert_awaited_once_with(- scope, test_user_id, expert, "mcp:h/t", "allow"+ scope, test_user_id, expert, rule_key, "allow")diff --git a/autogpt_platform/backend/backend/copilot/gate/__init__.py b/autogpt_platform/backend/backend/copilot/gate/__init__.pyindex 06c512f8fe..9d77bce681 100644--- a/autogpt_platform/backend/backend/copilot/gate/__init__.py+++ b/autogpt_platform/backend/backend/copilot/gate/__init__.py@@ -29,6 +29,7 @@ from .classifier import DecidedBy, supervisefrom .headline import Headlinefrom .policy import (DEFAULT_MODE,+ PARKABLE,AutopilotMode,Effect,Verdict,@@ -58,7 +59,6 @@ _ASK_FIRST = "Ask First is on for this chat, so this action needs your approval._OUTWARD = "This action reaches outside the platform, so it needs your approval."# One approval of a paid read over the ceiling buys one more dollar.CEILING_UNIT_MICRODOLLARS = 1_000_000-_PARKABLE = frozenset({Effect.SHELL, Effect.PLATFORM, Effect.EXTERNAL})# Paid steps that otherwise run in every mode; the costliest blocks are workspace.METERED = frozenset({Effect.READ, Effect.WORKSPACE})# The user's own word on the subject in this chat outranks the mode's rule.@@ -123,7 +123,7 @@ async def check_action(# Reads, workspace work and the ungated tools run in every mode and can# never have been parked, so they skip the review and rule lookups; a paid# step can be parked over the ceiling, so it cannot.- if effect_for(tool_name) not in _PARKABLE and not estimate_for(tool_name):+ if effect_for(tool_name) not in PARKABLE and not estimate_for(tool_name):return ALLOWsession_id = session.session_id@@ -160,7 +160,7 @@ async def check_action(# workspace work skip the Redis round trip.hit = (await chat_rules.rule_for(session_id, rule_key, user_id, session.expert_id)- if effect in _PARKABLE+ if effect in PARKABLEelse None)rule = hit.rule if hit else Nonediff --git a/autogpt_platform/backend/backend/copilot/gate/chat_rules_test.py b/autogpt_platform/backend/backend/copilot/gate/chat_rules_test.pyindex 00658c307a..7d7a7ed1da 100644--- a/autogpt_platform/backend/backend/copilot/gate/chat_rules_test.py+++ b/autogpt_platform/backend/backend/copilot/gate/chat_rules_test.py@@ -44,7 +44,7 @@ async def test_an_approved_card_rules_on_the_subject_it_named(redis):[(ReviewStatus.REJECTED, {"a": "mcp:h/t"}),(ReviewStatus.WAITING, {"a": "mcp:h/t"}),- # A bare tool or a held read names no subject, so a click cannot rule on it.+ # A held read or a money card offers no key, so a click cannot rule on it.(ReviewStatus.APPROVED, {}),],)@@ -121,7 +121,7 @@ def test_a_decline_names_its_scope_and_day(scope, otto, reason):assert hit.reason == reason-async def test_only_a_held_call_with_a_subject_offers_a_key():+async def test_a_held_call_offers_the_key_its_card_can_rule_on():calls = {"mcp": held.HeldCall(review_id="mcp",@@ -140,10 +140,18 @@ async def test_only_a_held_call_with_a_subject_offers_a_key():"read": held.HeldCall(review_id="read", tool_name="web_fetch", tool_call_id="c", args={}),+ # Parked over the spend ceiling: reads never consult a rule.+ "paid": held.HeldCall(+ review_id="paid",+ tool_name="consult_teammate",+ tool_call_id="c",+ args={},+ rule_key="consult_teammate",+ ),}with patch.object(held, "_held", AsyncMock(return_value=calls)):- keys = await held.subject_keys("s", ["mcp", "tool", "read", "gone"])- assert keys == {"mcp": "mcp:h/t"}+ keys = await held.subject_keys("s", ["mcp", "tool", "read", "paid", "gone"])+ assert keys == {"mcp": "mcp:h/t", "tool": "bash_exec"}async def test_an_unreadable_store_approves_without_a_rule():diff --git a/autogpt_platform/backend/backend/copilot/gate/gate_test.py b/autogpt_platform/backend/backend/copilot/gate/gate_test.pyindex 5345c15cf9..30202b83f1 100644--- a/autogpt_platform/backend/backend/copilot/gate/gate_test.py+++ b/autogpt_platform/backend/backend/copilot/gate/gate_test.py@@ -7,12 +7,20 @@ it should break these.from datetime import UTC, datetimefrom types import SimpleNamespace-from unittest.mock import AsyncMock, patch+from unittest.mock import AsyncMock, MagicMock, patchimport pytestfrom prisma.enums import ReviewStatus-from backend.copilot.gate import active_mode, chat_rules, check_action, gate_active+from backend.copilot.gate import (+ active_mode,+ chat_rules,+ check_action,+ gate_active,+ held,+)+from backend.copilot.gate import review as review_store+from backend.copilot.gate.chat_rules_test import _Redisfrom backend.copilot.gate.classifier import Judgementfrom backend.copilot.gate.headline import Headlinefrom backend.copilot.model import (@@ -26,6 +34,7 @@ from backend.copilot.model import (_GATE = "backend.copilot.gate"# The fixtures stub the rule lookup; the outage tests need the real one._REAL_RULE_FOR = chat_rules.rule_for+_REAL_OPEN_REVIEW = review_store.open_review_MODES: tuple[AutopilotMode, ...] = ("ask_first", "auto", "unsupervised")@@ -321,3 +330,67 @@ async def test_a_rejected_tool_says_the_user_declined_it(gate_on, clean_session_):decision = await check_action("delete_folder", {"id": "f"}, "u", _session())assert decision.reason == chat_rules.DECLINED++[email protected]("scope", ["chat", "expert", "team"])+ "mode, tool, rule, judged",+ [+ # The supervisor asked in Auto; allow skips it from then on.+ ("auto", "create_agent", "allow", False),+ # Ask First asks every time; judge hands the call to the supervisor.+ ("ask_first", "post_to_chat_platform", "judge", True),+ ],+)+async def test_a_rule_set_on_a_bare_tool_card_decides_its_next_call(+ gate_on, clean_session_state, scope, mode, tool, rule, judged+):+ """Park, answer with a rule on the key the gate stored, call again; a wider+ scope holds in another chat."""+ held_calls: dict[str, held.HeldCall] = {}++ async def remember(_session_id: str, call: held.HeldCall) -> bool:+ held_calls[call.review_id] = call+ return True++ reviews = MagicMock(get_or_create_human_review=AsyncMock())+ supervisor = AsyncMock(return_value=Judgement(allowed=False, reason="unsure"))+ with (+ patch(f"{_GATE}.held.remember", remember),+ patch(f"{_GATE}.held._held", AsyncMock(side_effect=lambda _: held_calls)),+ patch(f"{_GATE}.review_store.open_review", _REAL_OPEN_REVIEW),+ patch(f"{_GATE}.review.review_db", return_value=reviews),+ patch(f"{_GATE}.review.resolve_references", AsyncMock(return_value=[])),+ patch(f"{_GATE}.chat_rules.rule_for", _REAL_RULE_FOR),+ patch(f"{_GATE}.chat_rules.get_redis_async", AsyncMock(return_value=_Redis())),+ patch(+ f"{_GATE}.chat_rules.get_chat_session_metadata",+ AsyncMock(return_value=SimpleNamespace(expert_id=None)),+ ),+ patch(f"{_GATE}.supervise", supervisor),+ ):+ parked = await check_action(tool, {"n": 1}, "u", _session(mode))+ assert parked.review_id is not None+ card = reviews.get_or_create_human_review.await_args.kwargs["input_data"]+ assert card["chat_rules_allowed"] == ["allow", "judge"]++ answered = {parked.review_id: _row(ReviewStatus.APPROVED)}+ keys = await held.subject_keys("session-1", [parked.review_id])+ await chat_rules.set_answer_rules(+ "session-1",+ "u",+ answered,+ {parked.review_id: rule},+ keys,+ {parked.review_id: scope},+ )++ supervisor.reset_mock()+ supervisor.return_value = Judgement(allowed=True, reason="fine")+ chat = _session(mode)+ if scope != "chat":+ chat = chat.model_copy(update={"session_id": "session-2"})+ decision = await check_action(tool, {"n": 2}, "u", chat)+ assert decision.allowed+ assert supervisor.await_count == int(judged)+ assert reviews.get_or_create_human_review.await_count == 1diff --git a/autogpt_platform/backend/backend/copilot/gate/held.py b/autogpt_platform/backend/backend/copilot/gate/held.pyindex 7cb3fd8cb5..52c0eee087 100644--- a/autogpt_platform/backend/backend/copilot/gate/held.py+++ b/autogpt_platform/backend/backend/copilot/gate/held.py@@ -27,6 +27,7 @@ from backend.util.encryption import JSONCryptorfrom . import chat_rulesfrom . import review as review_store+from .policy import PARKABLE, effect_forif TYPE_CHECKING:from backend.api.features.graph_executions.review.model import (@@ -101,7 +102,8 @@ async def rule_key(session_id: str, review_id: str, tool_name: str) -> str:async def subject_keys(session_id: str, review_ids: list[str]) -> dict[str, str]:- """The subject each held card named; a bare tool or a held read names none."""+ """The key each held card can set a rule on; a held read or a money card+ has none."""if not review_ids:return {}try:@@ -118,7 +120,7 @@ async def subject_keys(session_id: str, review_ids: list[str]) -> dict[str, str]for review_id in review_idsif (call := held.get(review_id))and call.rule_key- and call.rule_key != call.tool_name+ and (call.rule_key != call.tool_name or effect_for(call.tool_name) in PARKABLE)}diff --git a/autogpt_platform/backend/backend/copilot/gate/policy.py b/autogpt_platform/backend/backend/copilot/gate/policy.pyindex 2311d33bcb..df5b095adf 100644--- a/autogpt_platform/backend/backend/copilot/gate/policy.py+++ b/autogpt_platform/backend/backend/copilot/gate/policy.py@@ -23,6 +23,10 @@ class Effect(str, Enum):UNGATED = "ungated"+# What the gate can hold for an answer, and so what a rule can be set on.+PARKABLE = frozenset({Effect.SHELL, Effect.PLATFORM, Effect.EXTERNAL})++class Verdict(str, Enum):RUN = "run"JUDGE = "judge"diff --git a/autogpt_platform/backend/backend/copilot/gate/review.py b/autogpt_platform/backend/backend/copilot/gate/review.pyindex d865411648..64336857f5 100644--- a/autogpt_platform/backend/backend/copilot/gate/review.py+++ b/autogpt_platform/backend/backend/copilot/gate/review.py@@ -30,7 +30,7 @@ from backend.data.db_accessors import review_dbfrom .classifier import DecidedByfrom .headline import Headline, headline_for-from .policy import DEFAULT_MODE, effect_for, is_irreversible+from .policy import DEFAULT_MODE, PARKABLE, effect_for, is_irreversiblefrom .references import Reference, listed_ids, resolve_referencesif TYPE_CHECKING:@@ -81,7 +81,7 @@ class GateReviewPayload(BaseModel):reason_kind: ReasonKind = "mode"# Which supervisor stage decided a ``supervisor`` card.decided_by: DecidedBy | None = None- # Only a card naming a subject can set a rule on it.+ # The rules this card can set on its subject, a bare tool included.chat_rules_allowed: list[Literal["allow", "judge"]] = []headline: Headline# A money card's estimate, spend so far and ceiling.@@ -158,9 +158,10 @@ def review_payload(reason=" ".join(reason.split())[:300],reason_kind=reason_kind,decided_by=decided_by,- # A money card rules on nothing: reads never consult a chat rule.chat_rules_allowed=(- ["allow", "judge"] if subject is not None and spend is None else []+ ["allow", "judge"]+ if _offers_rules(tool_name, subject, spend, reason_kind)+ else []),headline=(Headline(ask="Run", object=subject.name)@@ -307,13 +308,27 @@ def payload_headline(payload: dict[str, Any]) -> str:return Headline.model_validate(payload["headline"]).text+def _offers_rules(+ tool_name: str,+ subject: "GateSubject | None",+ spend: dict[str, int] | None,+ reason_kind: ReasonKind,+) -> bool:+ # A money card or a held read rules on nothing: neither consults a rule.+ if spend is not None or reason_kind == "content":+ return False+ return (subject.effect if subject else effect_for(tool_name)) in PARKABLE++def _payload_subject(tool_name: str, args: dict[str, Any], subject: "GateSubject | None") -> Subject:if subject is None:+ # A rule on a bare tool covers every call of it, so it is named by the+ # tool's action rather than this call's object.return Subject(key=tool_name,- name=_label(tool_name),+ name=headline_for(tool_name, {}).ask,effect=effect_for(tool_name).value,irreversible=is_irreversible(tool_name, args),)@@ -329,11 +344,6 @@ def _payload_subject()-def _label(tool_name: str) -> str:- label = tool_name.replace("_", " ")- return label[:1].upper() + label[1:]--def _field_labels(tool_name: str, shown: dict[str, Any]) -> list[FieldLabel]:"""Labels and order from the tool's own input schema, required first."""from backend.copilot.tools import get_tool # imports the gatediff --git a/autogpt_platform/backend/backend/copilot/gate/review_test.py b/autogpt_platform/backend/backend/copilot/gate/review_test.pyindex 3e6f45dad4..69c233ee52 100644--- a/autogpt_platform/backend/backend/copilot/gate/review_test.py+++ b/autogpt_platform/backend/backend/copilot/gate/review_test.py@@ -158,7 +158,7 @@ def test_a_bare_tool_is_its_own_subject():assert payload["subject"] == {"kind": "tool","key": "post_to_chat_platform",- "name": "Post to chat platform",+ "name": "Post a message","effect": "external","irreversible": False,"block_id": None,@@ -166,13 +166,31 @@ def test_a_bare_tool_is_its_own_subject():assert payload["mode"] == "auto"-def test_a_bare_tool_offers_no_rule_and_a_named_subject_offers_both():- assert review_payload("create_folder", {})["chat_rules_allowed"] == []- subject = mcp_subject("https://mcp.example.com/mcp", "create_issue")- payload = review_payload("run_capability", {}, subject)+ "tool, subject, kind",+ [+ # A bare tool the gate parks is its own subject, so a rule can name it.+ ("create_agent", None, "supervisor"),+ ("bash_exec", None, "mode"),+ ("post_to_chat_platform", None, "mode"),+ (+ "run_capability",+ mcp_subject("https://mcp.example.com/mcp", "create_issue"),+ "mode",+ ),+ ],+)+def test_a_parked_card_offers_both_rules(tool, subject, kind):+ payload = review_payload(tool, {}, subject, reason_kind=kind)assert payload["chat_rules_allowed"] == ["allow", "judge"]+def test_a_held_read_offers_no_rule():+ """A read's release is not a call the gate runs, so no rule covers it."""+ payload = review_payload("bash_exec", {}, reason_kind="content")+ assert payload["chat_rules_allowed"] == []++@pytest.mark.parametrize("status, age, expected",[diff --git a/autogpt_platform/backend/backend/copilot/gate/spend_test.py b/autogpt_platform/backend/backend/copilot/gate/spend_test.pyindex 3ee6d5c40a..a4a4f200fb 100644--- a/autogpt_platform/backend/backend/copilot/gate/spend_test.py+++ b/autogpt_platform/backend/backend/copilot/gate/spend_test.py@@ -444,6 +444,9 @@ def test_a_money_card_offers_no_chat_rule():sent = review_payload("t", {}, _SEND)assert sent["spend"] is Noneassert sent["chat_rules_allowed"] == ["allow", "judge"]+ # A paid tool with no subject is priced by the tool itself.+ bare = review_payload("consult_teammate", {}, None, spend, reason_kind="spend")+ assert bare["chat_rules_allowed"] == []async def test_flag_on_a_root_turn_opens_its_tree_and_its_chat(ledger, chat):diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/ApprovalQueue.stories.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/ApprovalQueue.stories.tsxindex 76249a6028..d7ee783c8f 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/ApprovalQueue.stories.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/ApprovalQueue.stories.tsx@@ -11,6 +11,7 @@ import { AttentionRow } from "../../../home/components/NeedsYou/components/Attenimport { ApprovalQueue } from "./ApprovalQueue";import { toApprovalItem } from "./helpers";import {+ createAgent,deleteFolder,folder,heldRead,@@ -104,6 +105,9 @@ export const RuleMenu: Story = {export const RuleMenuWithOtto: Story = { args: queueOf([mcpTool()]) };+// A bare tool's card rules on the tool itself.+export const RuleMenuOnATool: Story = { args: queueOf([createAgent()]) };+// A paid read over the task's spend ceiling.export const OverTheSpendCeiling: Story = { args: queueOf([spendCard()]) };diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/__tests__/chatRule.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/__tests__/chatRule.test.tsxindex fab5bc83a4..7c66b54147 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/__tests__/chatRule.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/__tests__/chatRule.test.tsx@@ -5,7 +5,7 @@ import { server } from "@/mocks/mock-server";import { render, screen, waitFor } from "@/tests/integrations/test-utils";import { CopilotChatActionsProvider } from "../../CopilotChatActionsProvider/CopilotChatActionsProvider";import { CopilotPendingReviews } from "../../CopilotPendingReviews/CopilotPendingReviews";-import { mail, mcpTool, CHAT_SESSION } from "./fixtures";+import { createAgent, mail, mcpTool, CHAT_SESSION } from "./fixtures";function serve(review: ReturnType<typeof mail> = mail("m1", ["allow", "judge"]),@@ -48,12 +48,15 @@ async function openMenu() {const MAIL = "Gmail Send";const MCP = "create_issue on mcp.linear.app";+const TOOL = "“Create an agent”";test.each([[`Approve ${MAIL} from now on`, "allow", mail("m1")],[`Let Otto judge ${MAIL} from now on`, "judge", mail("m1")],[`Approve ${MCP} from now on`, "allow", mcpTool("m1")],[`Let Otto judge ${MCP} from now on`, "judge", mcpTool("m1")],+ [`Approve ${TOOL} from now on`, "allow", createAgent("m1")],+ [`Let Otto judge ${TOOL} from now on`, "judge", createAgent("m1")],])("choosing %s approves the call and sets the %s rule for the Expert by default",async (item, rule, review) => {diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/__tests__/fixtures.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/__tests__/fixtures.tsindex 253753acfa..d143936b99 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/__tests__/fixtures.ts+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/__tests__/fixtures.ts@@ -134,6 +134,25 @@ export function shell(id = "shell") {});}+export function createAgent(id = "agent") {+ return heldReview({+ id,+ tool: "create_agent",+ mode: "auto",+ reason: "it creates an agent the user did not ask for.",+ reasonKind: "supervisor",+ subject: {+ kind: "tool",+ key: "create_agent",+ name: "Create an agent",+ effect: "platform",+ irreversible: false,+ },+ chatRules: ["allow", "judge"],+ headline: { ask: "Create an agent" },+ });+}+export function deleteFolder(id: string, folderId: string) {return heldReview({id,diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/__tests__/referenceCards.json b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/__tests__/referenceCards.jsonindex 13b4dc8075..26387a8a6f 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/__tests__/referenceCards.json+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/__tests__/referenceCards.json@@ -65,7 +65,7 @@"subject": {"kind": "tool","key": "delete_folder",- "name": "Delete folder",+ "name": "Delete library folder","effect": "platform","irreversible": false,"block_id": null@@ -73,7 +73,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Delete library folder","object": "Q3 reports",@@ -297,8 +297,8 @@}],"reference_totals": {- "agent_ids": 7,- "folder_id": 1+ "folder_id": 1,+ "agent_ids": 7},"tool_call_id": "call-move_agents_to_folder","turn": 1,@@ -306,7 +306,7 @@"subject": {"kind": "tool","key": "move_agents_to_folder",- "name": "Move agents to folder",+ "name": "Move agents into library folder","effect": "platform","irreversible": false,"block_id": null@@ -314,7 +314,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Move agents into library folder","object": "Archive",@@ -393,7 +393,7 @@"subject": {"kind": "tool","key": "pause_schedule",- "name": "Pause schedule",+ "name": "Pause a schedule","effect": "platform","irreversible": false,"block_id": null@@ -401,7 +401,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Pause a schedule","object": "Daily digest",@@ -478,7 +478,7 @@"subject": {"kind": "tool","key": "hire_expert",- "name": "Hire expert",+ "name": "Hire","effect": "platform","irreversible": false,"block_id": null@@ -486,7 +486,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Hire","object": "Ada",@@ -564,7 +564,7 @@"subject": {"kind": "tool","key": "message_session",- "name": "Message session",+ "name": "Message another chat","effect": "platform","irreversible": false,"block_id": null@@ -572,7 +572,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Message another chat","object": "Q3 planning",@@ -663,8 +663,8 @@}],"reference_totals": {- "expert_id": 1,- "credential_id": 1+ "credential_id": 1,+ "expert_id": 1},"tool_call_id": "call-grant_expert_credential","turn": 1,@@ -672,7 +672,7 @@"subject": {"kind": "tool","key": "grant_expert_credential",- "name": "Grant expert credential",+ "name": "Give a teammate an account","effect": "platform","irreversible": false,"block_id": null@@ -680,7 +680,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Give a teammate an account","object": "GitHub (work)",@@ -759,7 +759,7 @@"subject": {"kind": "tool","key": "edit_agent",- "name": "Edit agent",+ "name": "Edit an agent","effect": "platform","irreversible": false,"block_id": null@@ -767,7 +767,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Edit an agent","object": "Morning digest",@@ -842,7 +842,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Update preset","object": "Weekly digest",@@ -909,7 +909,7 @@"subject": {"kind": "tool","key": "delete_preset",- "name": "Delete preset",+ "name": "Delete a preset","effect": "platform","irreversible": false,"block_id": null@@ -917,7 +917,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Delete a preset","object": "New invoice email",@@ -984,7 +984,7 @@"subject": {"kind": "tool","key": "schedule_routine",- "name": "Schedule routine",+ "name": "Schedule a routine","effect": "platform","irreversible": false,"block_id": null@@ -992,7 +992,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Schedule a routine","object": "Month-end close",@@ -1098,7 +1098,7 @@"subject": {"kind": "tool","key": "install_expert_workflow",- "name": "Install expert workflow",+ "name": "Give a teammate a workflow","effect": "platform","irreversible": false,"block_id": null@@ -1106,7 +1106,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Give a teammate a workflow","object": null,@@ -1166,7 +1166,7 @@"subject": {"kind": "tool","key": "remove_expert_workflow",- "name": "Remove expert workflow",+ "name": "Take a workflow from a teammate","effect": "platform","irreversible": false,"block_id": null@@ -1174,7 +1174,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Take a workflow from a teammate","object": "Receipt matcher",@@ -1247,7 +1247,7 @@"subject": {"kind": "tool","key": "confirm_expert_change",- "name": "Confirm expert change",+ "name": "Confirm the team change","effect": "platform","irreversible": false,"block_id": null@@ -1255,7 +1255,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Confirm the team change","object": "Grace",@@ -1353,7 +1353,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Delete workspace file","object": "/reports/q3-report.pdf",@@ -1413,7 +1413,7 @@"subject": {"kind": "tool","key": "delete_preset",- "name": "Delete preset",+ "name": "Delete a preset","effect": "platform","irreversible": false,"block_id": null@@ -1421,7 +1421,7 @@"reason": "Ask First is on for this chat, so this action needs your approval.","reason_kind": "mode","decided_by": null,- "chat_rules_allowed": [],+ "chat_rules_allowed": ["allow", "judge"],"headline": {"ask": "Delete a preset","object": null,diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/components/ApprovalCard/ApprovalCard.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/components/ApprovalCard/ApprovalCard.tsxindex 671777b9d1..82a88813f9 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/components/ApprovalCard/ApprovalCard.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/components/ApprovalCard/ApprovalCard.tsx@@ -10,6 +10,7 @@ import {isBare,isHeldRead,reasonLine,+ ruleSubjectName,} from "../../helpers";import { ApprovalHeadline } from "../ApprovalHeadline";import { ApproveSplitButton } from "./ApproveSplitButton";@@ -45,7 +46,7 @@ export function ApprovalCard({<div className="grid grid-cols-2 gap-2 sm:flex sm:shrink-0 sm:flex-wrap"><ApproveSplitButtonlabel={read ? `Release to ${AUTOPILOT_NAME}` : "Approve"}- subjectName={item.subject.name}+ subjectName={ruleSubjectName(item.subject)}expertName={expertName}rules={read || item.spend ? [] : item.chatRulesAllowed}loading={status === "approving"}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/helpers.tsindex 26d9abf049..0b673a9add 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/helpers.ts+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ApprovalQueue/helpers.ts@@ -118,6 +118,11 @@ export function toApprovalItem(review: PendingHumanReviewModel): ApprovalItem {};}+// A rule on a bare tool covers every call of it, so it is named as an action.+export function ruleSubjectName(subject: ApprovalItem["subject"]) {+ return subject.kind === "tool" ? `“${subject.name}”` : subject.name;+}+// A row the server wrote no headline for still names its tool.export function fallbackAsk(toolName: string) {return `Run ${beautifyString(toolName.replace(/^run_/, "")).toLowerCase()}`;