Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions autobot-backend/services/autoresearch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@
Issue #2599: AutoBot-orchestrated loop + web search (M2).
"""

from .knowledge_synthesizer import ExperimentInsight, KnowledgeSynthesizer
from .prompt_optimizer import (
BenchmarkFn,
OptimizationSession,
OptimizationStatus,
PromptOptimizer,
PromptOptTarget,
PromptVariant,
)
from .scorers import (
HumanReviewScorer,
LLMJudgeScorer,
PromptScorer,
ScorerResult,
ValBpbScorer,
)
from .auto_research_agent import (
ApprovalGate,
AutoResearchAgent,
Expand Down Expand Up @@ -66,6 +82,20 @@
"ResearchHypothesis",
"SearchResult",
"SessionStatus",
# M3: Self-improvement (Issue #2600)
"PromptOptimizer",
"PromptOptTarget",
"PromptVariant",
"OptimizationSession",
"OptimizationStatus",
"BenchmarkFn",
"PromptScorer",
"ScorerResult",
"ValBpbScorer",
"LLMJudgeScorer",
"HumanReviewScorer",
"KnowledgeSynthesizer",
"ExperimentInsight",
# Routes
"router",
# OSINT Engine (Issue #1949)
Expand Down
43 changes: 43 additions & 0 deletions autobot-backend/services/autoresearch/auto_research_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,33 @@ async def _handle_approval_gate(
metrics.improvement_pct,
status_key,
)

# Dispatch notification for approval_needed event
try:
from services.notification_service import (
NotificationEvent,
NotificationService,
)

notification_service = NotificationService()
await notification_service.send(
event=NotificationEvent.APPROVAL_NEEDED,
workflow_id=f"autoresearch:{session.id}",
payload={
"experiment_id": experiment.id,
"topic": session.topic,
"improvement_pct": metrics.improvement_pct,
"val_bpb": metrics.result_val_bpb,
"baseline_val_bpb": metrics.baseline_val_bpb,
},
config=self._get_notification_config(session.id),
)
except Exception:
logger.exception(
"Failed to send approval notification for experiment %s",
experiment.id,
)

# Non-blocking poll with short timeout so we don't freeze the loop
decision = await self.approval_gate.wait_for_approval(
session_id=session.id,
Expand All @@ -822,6 +849,22 @@ async def _handle_approval_gate(
decision,
)

def _get_notification_config(self, session_id: str):
"""Return a default notification config for autoresearch approval events.

Args:
session_id: The autoresearch session ID used as the workflow ID.

Returns:
NotificationConfig scoped to the autoresearch session.
"""
from services.notification_service import NotificationConfig

return NotificationConfig(
workflow_id=f"autoresearch:{session_id}",
channels={"approval_needed": ["in_app"]},
)

# ------------------------------------------------------------------
# Private: session persistence
# ------------------------------------------------------------------
Expand Down
Loading
Loading