Skip to content

Merge Agent Ping into System Task framework #1014

@chubes4

Description

@chubes4

Summary

Agent Ping is currently a standalone pipeline step type (AgentPingStep) that POSTs pipeline context to external webhook URLs. It shares the same structural pattern as system tasks (self-configuring, job-tracked, ability-backed) but exists outside the SystemTask / TaskRegistry / TaskScheduler framework. This means it's only usable as a pipeline step — not standalone via CLI, REST, or scheduled cron.

This issue proposes converting Agent Ping from a standalone step type into a registered SystemTask, making it a first-class citizen in the system task framework while preserving all existing functionality and UX.

Motivation

  1. Architectural consistency — Agent Ping is an operation (send HTTP POST). System tasks are registered, schedulable, trackable operations. These are the same concept.
  2. Standalone execution — Currently agent ping is pipeline-bound. As a system task it gets wp datamachine system run agent_ping, REST POST /system/tasks/agent_ping/run, and scheduled cron for free.
  3. Fewer step types — The "Agent Ping" step type in the pipeline builder dropdown is replaced by the existing "System Task" step type with agent_ping selected from the task dropdown. Same UX, one fewer concept.
  4. Shared infrastructure — Prompt overrides, batch scheduling, undo, admin UI "Run Now" — all inherited from SystemTask base class.
  5. Extension ecosystem alignment — Third-party developers register tasks via datamachine_tasks filter. Agent ping follows the same pattern.

Plan

Phase 1: Create AgentPingTask

New file: inc/Engine/AI/System/Tasks/AgentPingTask.php

  • Extends SystemTask
  • Implements execute(int $jobId, array $params): void
  • Delegates to SendPingAbility for the actual HTTP POST logic
  • Moves webhook-specific config (URL, auth headers, reply_to) into task params
  • Registers via datamachine_tasks filter in SystemAgentServiceProvider::getBuiltInTasks()
class AgentPingTask extends SystemTask {
    public function execute(int $jobId, array $params): void {
        // Read params: webhook_url, prompt, auth_header_name, auth_token, reply_to
        // Resolve prompt from queue or configured value
        // Delegate to SendPingAbility
        // Report success/failure via completeJob()/failJob()
    }

    public function getTaskType(): string {
        return 'agent_ping';
    }

    public static function getTaskMeta(): array {
        return [
            'label'        => 'Agent Ping',
            'description'  => 'Send context to external webhook endpoints (Discord, Slack, custom)',
            'setting_key'  => null,
            'trigger_type' => 'manual',
            'supports_run' => true,
        ];
    }
}

Config params shape (stored in engine_data):

{
  "webhook_url": "https://discord.com/api/webhooks/...",
  "prompt": "Review this content",
  "auth_header_name": "",
  "auth_token": "",
  "reply_to": "",
  "from_queue": false
}

Phase 2: Add queue support to AgentPingTask

  • Agent Ping currently uses QueueableTrait in the step. As a system task, the prompt queue mechanism needs to be available.
  • Option A: AgentPingTask directly reads from the flow queue via QueueAbility::popFromQueue() when executed as a pipeline step (has flow_id and flow_step_id in params).
  • Option B: Move queue popping into the task's execute() method, checking for flow_step_id in params to determine if running in pipeline context.

Phase 3: Update SystemTaskStep for agent ping UX

File: inc/Core/Steps/SystemTask/SystemTaskStep.php

No changes needed. SystemTaskStep already handles any registered task type. When user selects "System Task" step type and picks agent_ping, it creates a child job and runs AgentPingTask::execute() synchronously. The existing SystemTaskSettings task dropdown will show "Agent Ping" automatically.

Phase 4: Remove standalone step type

Delete:

  • inc/Core/Steps/AgentPing/AgentPingStep.php
  • inc/Core/Steps/AgentPing/AgentPingSettings.php
  • inc/Core/Steps/AgentPing/ directory

Update data-machine.php:

  • Remove new AgentPingStep() from datamachine_load_step_types()
  • Remove AgentPingAbilities require/instantiation (ability moves to task delegation)

Phase 5: Keep existing surfaces intact

Keep as-is (no changes):

  • inc/Abilities/AgentPing/SendPingAbility.php — still the reusable HTTP layer
  • inc/Api/AgentPing.php — REST callback endpoints still work
  • inc/Api/Chat/Tools/SendPing.php — chat tool still works
  • inc/Abilities/AgentPingAbilities.php — may need adjustment since step no longer instantiates it, but the ability registration should persist for chat/REST/CLI use

Phase 6: Migration

File: inc/migrations.php

  • Add migration to convert existing agent_ping step types in flow configs to system_task step types with task: 'agent_ping' in handler_config.
  • The migration should:
    1. Query all flows with steps where step_type === 'agent_ping'
    2. Convert step_type to 'system_task'
    3. Move handler config to use task: 'agent_ping' key
    4. Preserve webhook_url, prompt, auth settings as task params

Files Changed

Action File Notes
Create inc/Engine/AI/System/Tasks/AgentPingTask.php New SystemTask subclass
Delete inc/Core/Steps/AgentPing/AgentPingStep.php Replaced by SystemTaskStep
Delete inc/Core/Steps/AgentPing/AgentPingSettings.php Replaced by SystemTaskSettings
Update inc/Engine/AI/System/SystemAgentServiceProvider.php Register agent_ping in getBuiltInTasks()
Update data-machine.php Remove AgentPingStep registration
Update inc/migrations.php Flow config migration for existing agent_ping steps
Keep inc/Abilities/AgentPing/SendPingAbility.php Unchanged — reusable HTTP layer
Keep inc/Api/AgentPing.php Unchanged — REST callbacks
Keep inc/Api/Chat/Tools/SendPing.php Unchanged — chat tool

New Capabilities Gained

After this change, agent ping can be triggered from:

Surface How New?
Pipeline step System Task step → select "Agent Ping" Existing UX
CLI wp datamachine system run agent_ping --params='{"webhook_url":"..."}' New
REST POST /datamachine/v1/system/tasks/agent_ping/run New
Scheduled cron TaskScheduler::schedule('agent_ping', ...) via daily/event trigger New
Chat tool send_ping tool Existing
Ad-hoc ability wp_get_ability('datamachine/send-ping') Existing
Admin UI "Run Now" button on system tasks page New

Blockers / Open Questions

  1. Queue support in system tasksQueueableTrait is currently a step-level concern. System tasks don't have a queue concept. Need to decide if AgentPingTask reads from the flow queue directly (coupling to pipeline context) or if queue support should be added to the SystemTask base class.
  2. Callback transients — The REST callback system (AgentPing class) stores transients keyed by callback_id. This doesn't need to change, but we should confirm the callback flow still works when the ping originates from a system task job instead of a pipeline step job.
  3. Frontend config — The admin UI for configuring agent ping webhook URLs currently lives in AgentPingSettings. After migration, this config needs to work within SystemTaskSettings's JSON params field, or we need a custom settings renderer for the agent_ping task type within the system task config modal.
  4. Prompt overrides — Agent ping doesn't currently have prompt definitions. As a system task it could optionally expose getPromptDefinitions() for admin-editable prompt templates.

Definition of Done

  • AgentPingTask registered in TaskRegistry and executable standalone
  • wp datamachine system run agent_ping works
  • POST /system/tasks/agent_ping/run works
  • Existing pipeline flows with agent_ping steps auto-migrate to system_task steps
  • Webhook sending, Discord formatting, multi-URL dispatch all work as before
  • REST callback endpoints still work
  • Chat tool still works
  • AgentPingStep and AgentPingSettings deleted
  • No regression in existing system tasks (alt text, linking, etc.)

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