createHarness(), built once per activation by harness(card) in managed/agent.ts:
callHarness(card) builds a second harness for calls when a tool is marked ask: a turn on a call is not a durable run, and nobody can approve while the caller waits, so every ask becomes deny for that harness and the agent says so once in the logs, {"voiceTools":"left out on calls","tools":[…]}. Without any ask, calls use the very same instance.
The class fills seven fields of the spec.
portsisbuildPorts(), the instance’s own runtime ports.modelis the host’smodel, or elsechatLanguageModelforspec.model.observeModelErrorswraps it so that a failed run can record the model’s own error message.toolsis the tool set asapplyApprovalsleaves it: the toolsspecToolsbuilds fromagent.json(Tools, Approvals and Limits), with the host’s merged on top.activeToolsis passed only when a tool is denied.authorizationis passed only when a tool is markedask.instructionsisspec.instructions, with the memory summary appended when memory is on.limitsis{ steps }, fromspec.limits.stepsorDEFAULT_STEPS.
defineManagedAgent(spec, host), supplies the tools and can replace the model. Extending the Managed Agent lists its fields.
The ports are built over the instance itself:
super(ctx, env) is the runtime SDK’s constructor(), and createRuntimeAgentHarnessPorts(this, { environmentKeys }) is createRuntimeAgentHarnessPorts().
thisis the instance. The harness reaches its storage and scheduler only through the ports.environmentKeysis the host’s. It names the bindings that cross into the ports, and none cross without it.setAgentHarnessAuthorizationProvider, from@telnyx/edge-runtime/internal, registers the host’sauthorizationas the instance’s authorization port. Approvals fail closed without it.
createHarnessWithScheduling()adds tools with which the model schedules its own follow-ups.createVirtualWorkspace()adds a per-instance text store with skills, which the model reads and writes through tools.HarnessMiddlewarewraps a turn, a model step or a tool call.