Skip to content

Agent-side Athena Decision Service integration #198

@vredchenko

Description

@vredchenko

Summary

Implement Athena Decision Service integration in the Agent (not backend). This follows the separation of concerns principle where:

  • Backend handles recommendations (ML predictions stored and routed via SSE)
  • Agent handles instructions (user confirmation, conversion to microscope format, execution via AthenaAPI)

Background

PR #190 originally implemented Athena integration in the backend (consumer.py), which violated the architectural boundary. That approach was removed. This issue captures the correct agent-side approach.

Implementation Notes

Decision Type Mapping

  • Grid square predictions → DecisionType.GRID_SQUARE_SELECTION
  • Foil hole predictions → DecisionType.FOIL_HOLE_SELECTION
  • Decision value: "true" if prediction > 0.5, else "false"
  • Details field: include prediction value and model name

Bulk vs Single Requests

  • Single foilhole: Use POST /api/v1/Decision
  • Multiple foilholes: Use POST /api/v1/Decisions (bulk endpoint)
  • Reason: Prevents microscope blocking - sequential decisions would cause the microscope to process the first and block subsequent ones

Plugin Configuration

  • Use PluginType.CUSTOM
  • decidedBy: "smartem_ml_model"

User Confirmation Modes

The agent should support three modes:

  1. Auto-accept: Automatically forward all recommendations as instructions
  2. Manual confirm: Present each recommendation to user for approval
  3. Observe only: Display recommendations but user takes manual action outside system

Tasks

  • Add recommendation instruction handlers to agent (fs_watcher.py)
  • Create Athena handler module for decision conversion and submission
  • Implement user confirmation flow (3 modes)
  • Connect to AthenaAPI for actual instruction submission
  • Add configuration for user confirmation mode
  • Test with Athena mock server

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions