Skip to main content
The run executes as a task on the instance. The harness’s tasks arrive at onTask in managed/agent.ts, which hands them to the harness:
onTask(name, payload, info) overrides the runtime SDK’s onTask(), the fallback for a task whose name is not a method of the class.
  • The harness’s task names start with HARNESS_TASK_PREFIX, __telnyx_agent_harness_, and name no method of the class, so the tasks arrive here.
  • DELIVERY_TASK, __telnyx_acp_deliver, is the next try at a reply the channel refused; Delivery has the window.
  • Any other task goes to super.onTask, the runtime’s default, which treats it as delivered.
this.messages.last() is last() on the message log. Runs are dispatched one at a time, so every message past the seq it returns is this run’s. harness.dispatch({ name, payload }) is dispatch().
  • name and payload are the task as the harness queued it.
  • It executes the run’s turn and returns the run’s HarnessRun as the turn left it.
Inside dispatch, three things happen.
  • The model is called with the instructions and the conversation’s message log.
  • Tools run, subject to their approvals.
  • Each assistant message is appended to the log as it lands.
When dispatch returns, noteRun writes the outcome to state, through the runtime SDK:
  • getState() returns the runs already noted, so a redelivered task does not note a run twice.
  • last() returns the newest message. It is the reply only when its seq is past before, its role is assistant and it has text.
  • now() is the time a completed or failed outcome records as at.
  • setState() merges the patch. A null in it deletes a key, as it deletes awaitingApprovalRunId once that run ends.
The outcome decides the keys written. The state stream carries each of these, which is how invoke ends with a reply, or with a line that says why there is none. With memory on, a completed run’s exchange is pushed to Agent Memory under the run’s id. Delivery is the last step.