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.
Address review: held Instantly never stalls the pipeline and is announced
Ethanf1c48c711010
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f50453b..5804da0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,10 +10,17 @@ minor versions can still change behaviour.### Fixed- Keep local website requests out of private networks, including redirects and- DNS rebinding. Preserve the original hostname for TLS verification.-- Hold legacy Instantly campaign deployment and replies when approval is- required, instead of silently bypassing the setting. Instantly autopilot now- requires explicitly setting `channels.email.require_approval: false`.+ DNS rebinding. Preserve the original hostname for TLS verification. Website+ fetching (search, company sites, profiling, the training crawler) now ignores+ `HTTP_PROXY`/`HTTPS_PROXY`, so it can't be routed around that boundary; mail+ and API integrations are unchanged. `harvey train` refuses local or intranet+ URLs and says so.+- **Instantly users: check `require_approval`.** Instantly has no per-email+ approval queue, so with `channels.email.require_approval: true` (the default)+ Harvey now holds campaign deployment and hands replies to a human instead of+ silently bypassing the setting. `harvey run` and `harvey status` say when this+ is happening; prospecting and drafting carry on. Set+ `require_approval: false` for Instantly autopilot.- Disable LinkedIn by default in the model, sample config, and product trainer;save the setup wizard's explicit LinkedIn choice when updating a config.- Protect the local dashboard with an access token, restrict requests to trusteddiff --git a/harvey/agents/handler.py b/harvey/agents/handler.pyindex 7b9f8e0..cdb17cb 100644--- a/harvey/agents/handler.py+++ b/harvey/agents/handler.py@@ -11,7 +11,7 @@ import loggingfrom datetime import datetime, timezonefrom harvey.brain import Brain, BrainUnavailable-from harvey.config import HarveyConfig, EnvConfig+from harvey.config import HarveyConfig, EnvConfig, legacy_sending_heldfrom harvey.humanize import humanize, humanizer_enabledfrom harvey.integrations.instantly import InstantlyClientfrom harvey.integrations.mail_provider import NATIVE_PROVIDERS, get_mail_provider@@ -259,9 +259,11 @@ class Handler:old_stage = convo.stageconvo.stage = self._determine_stage(intent, convo.stage, reply_text)- # 2b. Draft the reply now, while nothing is stored yet.+ # 2b. Draft the reply now, while nothing is stored yet. A held+ # Instantly setup can't send it, so don't spend a model call on it.+ held = not self.is_native and legacy_sending_held(self.config)response = ""- if intent in AUTO_REPLY_INTENTS:+ if intent in AUTO_REPLY_INTENTS and not held:response = await self._generate_response(intent, reply_text, prospect, convo)# 2c. Store the conversation in one write.@@ -320,6 +322,20 @@ class Handler:logger.warning(f"Handler: No auto-reply policy for intent '{intent}'. Skipping reply.")return+ if held:+ # Instantly has no approval queue: a human answers this one.+ await self.state.update_conversation(convo.id, status="needs_human")+ await self.state.log_action(+ action_type="escalation", agent="handler",+ details={"prospect_email": lead_email, "reason": "instantly_approval_required",+ "reply_preview": reply_text[:200]},+ )+ logger.warning(+ f"Handler: reply from {lead_email} held for a human: Instantly can't "+ "queue replies for approval while require_approval is true."+ )+ return+# For interested, objection, question, wrong_person — the reply drafted aboveif not response:# No usable draft from a working provider: hand it to a human@@ -344,18 +360,6 @@ class Handler:response, prospect, convo, reply_meta or {}, intent)elif reply_uuid:- if getattr(self.config.channels.email, "require_approval", True):- await self.state.update_conversation(convo.id, status="needs_human")- await self.state.log_action(- action_type="escalation", agent="handler",- details={"prospect_email": lead_email, "reason": "instantly_approval_required"},- )- logger.warning(- "Handler: Instantly reply held for human handling because "- "require_approval is true. Use a native provider for outbox "- "review, or explicitly disable require_approval for autopilot."- )- returnresult = await self.instantly.send_reply(reply_uuid, response)if result is not None:# Add our response to conversationdiff --git a/harvey/cli.py b/harvey/cli.pyindex 580ddfb..bcd4423 100644--- a/harvey/cli.py+++ b/harvey/cli.py@@ -4,6 +4,7 @@ import argparseimport asyncioimport subprocessimport sys+import textwrapfrom pathlib import Path@@ -208,6 +209,15 @@ def cmd_status(args):by_provider = summary.get("usage_today_by_provider", {})print(f" Claude calls today: {by_provider.get('claude', summary['usage_today'])}")print(f" Codex calls today: {by_provider.get('codex', 0)}")+ from harvey.config import ConfigError, load_config, sending_notice+ try:+ notice = sending_notice(load_config())+ except ConfigError:+ notice = ""+ if notice:+ print(" Sending: HELD")+ print(textwrap.fill(notice, width=72, initial_indent=" ",+ subsequent_indent=" "))from harvey.brain import BRAIN_STATUS_KEY, Brain, active_brain_statusfrom harvey.config import ConfigError, load_brain_configtry:diff --git a/harvey/config.py b/harvey/config.pyindex 0acb5f6..3822555 100644--- a/harvey/config.py+++ b/harvey/config.py@@ -95,6 +95,29 @@ class EmailChannelConfig(BaseModel):return v+def legacy_sending_held(config) -> bool:+ """True when Instantly is the provider and approval is required.++ Instantly has no per-email approval queue, so with require_approval on+ Harvey holds campaign deployment and hands replies to a human.+ """+ email = getattr(getattr(config, "channels", None), "email", None)+ return (getattr(email, "provider", "") == "instantly"+ and bool(getattr(email, "require_approval", True)))+++def sending_notice(config) -> str:+ """A plain-language warning when outbound sending is held by config, or ""."""+ if not legacy_sending_held(config):+ return ""+ return (+ "Instantly sending is held: channels.email.require_approval is true, and "+ "Instantly has no approval queue. Campaigns stay as drafts and replies go to "+ "a human (dashboard Activity tab). Set require_approval: false to let Instantly "+ "send automatically, or switch to gmail, microsoft or smtp to approve each email."+ )++class LinkedInChannelConfig(BaseModel):enabled: bool = Falsemax_daily_connections: int = 20diff --git a/harvey/main.py b/harvey/main.pyindex 669a2b1..0d16069 100644--- a/harvey/main.py+++ b/harvey/main.py@@ -9,7 +9,9 @@ from datetime import datetime, time, timedeltaimport pytzfrom harvey.brain import Brain-from harvey.config import ConfigError, load_config, load_env, HarveyConfig+from harvey.config import (+ ConfigError, load_config, load_env, HarveyConfig, legacy_sending_held, sending_notice,+)from harvey.pipeline import run_profile_stagefrom harvey.state import StateManager@@ -94,9 +96,13 @@ async def decide_next_action(draft_campaigns = summary.get("draft_campaigns", 0) or 0open_conversations = summary.get("open_conversations", 0) or 0+ # Held Instantly drafts can't deploy; choosing send_campaign for them+ # every cycle would starve the writer and scout forever.+ deployable = 0 if legacy_sending_held(config) else draft_campaigns+if open_conversations > 0:action, reason = "handle_replies", f"{open_conversations} open conversation(s) waiting"- elif draft_campaigns > 0:+ elif deployable > 0:action, reason = "send_campaign", f"{draft_campaigns} draft campaign(s) ready to deploy"elif new_prospects > 0:action, reason = "write_campaign", f"{new_prospects} new prospect(s) with no drafts ready"@@ -179,6 +185,11 @@ async def heartbeat(stop_event: asyncio.Event | None = None):+ (f" ({brain.model})" if brain.model else "")+ ". Change brain.provider in harvey.yaml to switch.")+ notice = sending_notice(config)+ if notice:+ logger.warning("=" * 60)+ logger.warning(notice)+ logger.warning("=" * 60)await state.init_db()logger.info("Database initialized.")diff --git a/harvey/trainer.py b/harvey/trainer.pyindex 377bb31..c61203e 100644--- a/harvey/trainer.py+++ b/harvey/trainer.py@@ -20,7 +20,7 @@ from dotenv import load_dotenvfrom harvey.brain import Brainfrom harvey.config import BrainConfig, load_brain_config-from harvey.public_http import public_http_client+from harvey.public_http import UnsafeURLError, public_http_clientfrom harvey.state import StateManagerlogger = logging.getLogger("harvey.trainer")@@ -204,8 +204,12 @@ class FallbackCrawler:on each crawled page until it hits the max_pages limit."""+ # Set when a page was refused for pointing at a local or private address.+ blocked = False+async def crawl(self, base_url: str, max_pages: int = 100) -> dict[str, str]:"""Recursively crawl a website by following internal links."""+ self.blocked = Falsepages: dict[str, str] = {}visited: set[str] = set()domain = urlparse(base_url).netloc@@ -275,6 +279,9 @@ class FallbackCrawler:lines = [line.strip() for line in text.splitlines() if line.strip()]return raw_html, "\n".join(lines)+ except UnsafeURLError:+ self.blocked = True+ return "", ""except Exception as e:logger.debug(f"Failed to fetch {url}: {e}")return "", ""@@ -475,7 +482,12 @@ class Trainer:self.scraped_pages = await crawler.crawl(base_url, max_pages=max_pages)if not self.scraped_pages:- print("\nERROR: Could not scrape any pages. Check the URL.")+ if getattr(crawler, "blocked", False):+ print(f"\nERROR: {base_url} points to a local or private address. Harvey only")+ print("learns from public websites, so it never reaches into your own network.")+ print("Train on the live public site instead.")+ else:+ print("\nERROR: Could not scrape any pages. Check the URL.")return Noneprint(f" Done! Crawled {len(self.scraped_pages)} pages.\n")diff --git a/tests/test_security_defaults.py b/tests/test_security_defaults.pyindex f337e39..479841d 100644--- a/tests/test_security_defaults.py+++ b/tests/test_security_defaults.py@@ -109,3 +109,59 @@ def test_setup_saves_explicit_linkedin_choice_for_existing_config(tmp_path, monkwizard.config = {"channels": {"linkedin": {"enabled": enabled}}}wizard._write_config()assert yaml.safe_load(path.read_text())["channels"]["linkedin"]["enabled"] is enabled+++# ── a held Instantly setup stays visible and never stalls the pipeline ──++async def test_held_instantly_reply_spends_no_model_call(state):+ await state.add_prospect(Prospect(first_name="Jane", last_name="Doe", company="Acme",+ title="Owner", email="[email protected]"))+ handler = Handler(None, state, legacy_config(), EnvConfig())+ handler.instantly = AsyncMock()+ handler._classify_intent = AsyncMock(return_value="interested")+ handler._generate_response = AsyncMock(return_value="Happy to help.")+ await handler._process_reply("[email protected]", "Sounds good, tell me more", "reply-id")+ handler._generate_response.assert_not_awaited()+ handler.instantly.send_reply.assert_not_awaited()+ assert len(await state.get_conversations_by_status("needs_human")) == 1++[email protected]("new, expected", [(30, "write_campaign"), (0, "prospect")])+async def test_held_drafts_do_not_block_writing_or_prospecting(new, expected):+ # A held Instantly draft must not win "send_campaign" every cycle and+ # starve the writer and scout forever.+ from harvey.main import decide_next_action+ summary = {"prospects": {"new": new}, "draft_campaigns": 1, "open_conversations": 0}+ assert await decide_next_action(None, None, legacy_config(), summary=summary) == expected+++async def test_drafts_still_deploy_on_instantly_autopilot_and_native_providers():+ from harvey.main import decide_next_action+ summary = {"prospects": {"new": 30}, "draft_campaigns": 1, "open_conversations": 0}+ assert await decide_next_action(None, None, legacy_config(False), summary=summary) == "send_campaign"+ native = legacy_config()+ native.channels.email.provider = "gmail"+ assert await decide_next_action(None, None, native, summary=summary) == "send_campaign"+++def test_held_instantly_is_announced_plainly():+ from harvey.config import legacy_sending_held, sending_notice+ assert legacy_sending_held(legacy_config()) is True+ assert legacy_sending_held(legacy_config(False)) is False+ notice = sending_notice(legacy_config())+ assert "Instantly" in notice and "require_approval: false" in notice+ assert sending_notice(legacy_config(False)) == ""+ native = legacy_config()+ native.channels.email.provider = "gmail"+ assert sending_notice(native) == ""+++async def test_training_on_a_local_url_says_why_it_was_refused():+ from harvey.trainer import FallbackCrawler+ crawler = FallbackCrawler()+ assert await crawler.crawl("http://localhost:3000", max_pages=3) == {}+ assert crawler.blocked is True