Task Dispatch and Routing Logs - AGI-Corporation/frontier-os-app-builder GitHub Wiki

Task Dispatch and Routing Logs

Navigation: [Home]] ](/AGI-Corporation/frontier-os-app-builder/wiki/[Core-Concepts) | [Evolution Bridge Service]] | Self-Evolving Agent Structures


Overview

Task dispatch is the core action in agent.bay: a user funds a task against a pipeline role, the Evolution Bridge routes it to the pipeline endpoint, and routing logs capture the entire round-trip. This page covers the full lifecycle from initiation to completion and the observability layer that powers self-evolution.


Task Lifecycle

1. User submits task form (title, description, role, FND amount)
       ↓
2. x402 payment submitted on-chain β†’ transactionHash returned
       ↓
3. bridge.dispatchTask({ pipelineId, role, title, description, amountFnd, transactionHash })
       ↓
4. Bridge verifies transactionHash (x402 layer)
       ↓
5. Bridge deducts amountFnd from prepaid balance (Bitrefill layer)
       ↓
6. Outbound TaskRoutingLog created (direction: 'outbound')
       ↓
7. EvolutionTask created with status: 'running'
       ↓
8. Bridge POSTs DispatchTaskParams to pipeline endpoint
       ↓
9. Pipeline executes role(s) and returns result
       ↓
10. Inbound TaskRoutingLog created (direction: 'inbound')
        ↓
11. Task status set to 'completed' (or 'failed' on error)
        ↓
12. Pipeline taskCount incremented
        ↓
13. Evolution engine receives routing logs as feedback input

Dispatching a Task

Input: DispatchTaskParams

interface DispatchTaskParams {
  pipelineId: string          // Target pipeline ID
  role: EvolutionAgentRole    // 'observer' | 'architect' | 'auditor' | 'planner'
  title: string               // Short label for this task
  description: string         // Full instructions for the agent
  amountFnd: number           // FND to draw from prepaid balance
  transactionHash: string     // x402 on-chain payment reference
}

Example: Dispatching to the Bug Repair Loop

const bridge = createEvolutionBridgeService()

const task = await bridge.dispatchTask({
  pipelineId: 'ralph-hive-bug-repair',
  role: 'observer',
  title: 'Scan prod logs for null pointer errors',
  description: 'Review the last 6 hours of application logs on prod-01 and identify any null pointer exceptions with their stack traces and frequency.',
  amountFnd: 5.0,
  transactionHash: '0x7f3a9b2e...'
})

console.log(task.status)  // 'running'
console.log(task.id)      // use to poll or fetch logs

Output: EvolutionTask

interface EvolutionTask {
  id: string
  agentId: string
  agentName: string
  role: EvolutionAgentRole
  title: string
  description: string
  status: 'pending' | 'running' | 'completed' | 'failed'
  transactionHash: string
  amountFnd: number
  createdAt: string
  updatedAt: string
  completedAt?: string
  logs: TaskRoutingLog[]
}

Routing Logs

Routing logs are the wire-level record of every task round-trip. They serve as:

  1. Operational observability β€” debug task failures and latency.
  2. Payment audit trail β€” prove when a payment was committed and whether the pipeline honored it.
  3. Evolution input β€” the raw data that self-evolving pipelines use to improve over time.

TaskRoutingLog Schema

interface TaskRoutingLog {
  id: string
  taskId: string
  direction: 'inbound' | 'outbound'
  payload: Record<string, unknown>
  statusCode: number
  timestamp: string    // ISO 8601
  duration: number     // Round-trip time in milliseconds
}

Outbound Log

Created when the Evolution Bridge dispatches the task to the pipeline endpoint.

// Example outbound log
{
  id: 'log-001',
  taskId: 'task-abc123',
  direction: 'outbound',
  payload: {
    pipelineId: 'ralph-hive-bug-repair',
    role: 'observer',
    title: 'Scan prod logs...',
    amountFnd: 5.0,
    transactionHash: '0x7f3a9b2e...'
  },
  statusCode: 202,
  timestamp: '2026-03-29T16:01:00.000Z',
  duration: 0    // Outbound: measured at dispatch
}

Inbound Log

Created when the pipeline endpoint responds with a result.

// Example inbound log
{
  id: 'log-002',
  taskId: 'task-abc123',
  direction: 'inbound',
  payload: {
    result: 'Found 3 null pointer exceptions in auth-service. Stack traces attached.',
    confidence: 0.94
  },
  statusCode: 200,
  timestamp: '2026-03-29T16:01:03.412Z',
  duration: 3412    // 3.4 seconds round-trip
}

Fetching Routing Logs

// Get all logs for a specific task
const logs = await bridge.getRoutingLogs('task-abc123')

// Get all logs across all tasks
const allLogs = await bridge.getRoutingLogs()

// Filter for only failed tasks
const failedLogs = allLogs.filter(l => l.statusCode >= 400)

// Calculate average round-trip time
const inbound = allLogs.filter(l => l.direction === 'inbound')
const avgDuration = inbound.reduce((sum, l) => sum + l.duration, 0) / inbound.length

Status Codes

Status Code Meaning
200 Pipeline completed task successfully
202 Task accepted, processing async
400 Invalid dispatch params
402 Payment verification failed (x402)
429 Pipeline rate limit exceeded
500 Pipeline internal error
503 Pipeline endpoint unavailable

Error Handling

try {
  const task = await bridge.dispatchTask(params)
} catch (err) {
  if (err.statusCode === 402) {
    // Payment verification failedβ€”check transactionHash
  } else if (err.statusCode === 503) {
    // Pipeline is downβ€”check syncedAt, trigger syncPipeline()
  }
}

On failure, the task is marked status: 'failed' and an inbound log with the error statusCode is recorded. Failed tasks still consume their routing log entry for audit purposes but FND refund behavior is pipeline-owner-configurable.


Routing Logs and Self-Evolution

Routing logs are the primary data feed for self-evolving agent behavior:

  • Duration patterns reveal which task types are slow and need optimization.
  • Failed status codes identify which problem descriptions the agent struggles with, feeding prompt refinement.
  • Payload patterns across completed tasks teach the agent which description styles yield better results.
  • amountFnd / duration ratio provides an economic efficiency signal for pricing and resource allocation.

See Self-Evolving Agent Structures for how this data is consumed by the evolution engine.


Related Pages