Skip to content

Autonomous AI sales agent powered by Claude Code or Codex. Finds prospects, writes cold emails, sends campaigns, handles replies, books meetings. No API keys needed — runs on your Claude or Codex subscriptions.

Refuse an Outbox edit the sender would block, and say why

Ethan2f39c6725e4d
diff --git a/harvey/dashboard.py b/harvey/dashboard.py
index 7bb3375..b02b8bb 100644
--- a/harvey/dashboard.py
+++ b/harvey/dashboard.py
@@ -882,6 +882,17 @@ async def outbox_edit(item_id: str, request: Request):
if not subject or not text:
return JSONResponse({"success": False, "message": "Subject and body are both required."},
status_code=400)
+ # The sender re-checks every email before it goes out; an edit it would
+ # block is refused now, while the reviewer can still fix it, instead of
+ # failing quietly at send time. Content rules only: the recipient isn't
+ # something an edit can change.
+ from harvey.gate import pre_send_check
+ gate = pre_send_check("[email protected]", subject, text)
+ if not gate:
+ return JSONResponse({"success": False,
+ "message": "The sender would have blocked this: "
+ + "; ".join(gate.reasons)},
+ status_code=400)
try:
state = _state()
await state.init_db()
diff --git a/tests/test_outbox_review.py b/tests/test_outbox_review.py
index 4795ee9..b74449e 100644
--- a/tests/test_outbox_review.py
+++ b/tests/test_outbox_review.py
@@ -100,3 +100,22 @@ def test_edit_needs_both_subject_and_body(client):
json={"subject": " ", "body": "text"}).status_code == 400
assert client.post(f"/api/outbox/{item_id}/edit",
json={"subject": "s"}).status_code == 400
+
+
+ "Hi {{first_name}},\n\nQuick one.\n\nHaris", # merge tag a person typed
+ "Hi there,\n\n<a href='x'>click</a>\n\nHaris", # HTML
+])
+def test_an_edit_the_sender_would_block_is_refused_with_the_reason(client, body):
+ state, item_id = asyncio.run(_seed(client.db_path))
+ r = client.post(f"/api/outbox/{item_id}/edit", json={"subject": "your portal", "body": body})
+ assert r.status_code == 400
+ assert "blocked" in r.json()["message"]
+ assert asyncio.run(state.get_outbox_item(item_id))["subject"] == "your client portal"
+
+
+def test_editing_needs_the_dashboard_token(client):
+ _, item_id = asyncio.run(_seed(client.db_path))
+ r = client.post(f"/api/outbox/{item_id}/edit", headers={"Authorization": ""},
+ json={"subject": "s", "body": "b"})
+ assert r.status_code in (401, 403)