coleam00/Archon · error

missing_assistant_message

missing_assistant_message

Error message

missing_assistant_message

What it means

buildResultChunk in the Pi event bridge emits a result chunk with isError:true and errorSubtype 'missing_assistant_message' when agent_end fires but the transcript contains no assistant message. Per the source comment this should not happen in healthy Pi runs; the bridge surfaces it loudly (warn log 'pi.event-bridge.result_missing_assistant_message') so orchestrators do not treat a broken session as a clean completion.

Source

Thrown at packages/providers/src/community/pi/event-bridge.ts:162

    .filter(b => b.type === 'text')
    .map(b => b.text ?? '')
    .join('');
}

/**
 * Build the terminal `result` chunk from the final `agent_end` event. Pulls
 * usage/stopReason/error from the last assistant message in the returned
 * transcript. When the agent ended in error, surfaces it as `isError: true`.
 */
export function buildResultChunk(messages: readonly unknown[]): MessageChunk {
  const last = [...messages].reverse().find(isAssistantMessage);
  if (!last) {
    // agent_end fired with no assistant message in the transcript. This
    // shouldn't happen in healthy Pi runs — surface it as a loud error
    // rather than a silent success so orchestrators don't treat a broken
    // session as a clean completion.
    getLog().warn('pi.event-bridge.result_missing_assistant_message');
    return { type: 'result', isError: true, errorSubtype: 'missing_assistant_message' };
  }

  const tokens = usageToTokens(last.usage);
  const isError = last.stopReason === 'error' || last.stopReason === 'aborted';

  const chunk: MessageChunk = {
    type: 'result',
    tokens,
    ...(tokens.cost !== undefined ? { cost: tokens.cost } : {}),
    ...(last.stopReason ? { stopReason: last.stopReason } : {}),
    ...(typeof last.responseModel === 'string' && last.responseModel.length > 0
      ? { resolvedModel: { id: last.responseModel } }
      : {}),
    ...(isError
      ? {
          isError: true,
          errorSubtype: last.stopReason,
          // Surfacing errorMessage in errors[] is what makes the executor's

View on GitHub (pinned to 0773b97458)

Solutions

  1. Check the pi.event-bridge.result_missing_assistant_message warn and surrounding Pi session logs for the earliest failure.
  2. Verify Pi provider authentication and connectivity — an immediate upstream failure yields no assistant message.
  3. Re-run the workflow node; a transient transport drop is the usual cause.
  4. If reproducible, run the same prompt through Pi directly to see whether the model emits any events; upgrade the Pi SDK if event ordering changed.
Defensive patterns

Strategy: type-guard

Validate before calling

// before trusting a Pi run result
const result = await runPiNode(node);
if (result.isError && result.errorSubtype === 'missing_assistant_message') {
  throw new Error('Pi session produced no assistant output — check provider auth/transport, then retry');
}

Type guard

function isMissingAssistantResult(chunk: unknown): chunk is { type: 'result'; isError: true; errorSubtype: 'missing_assistant_message' } {
  const c = chunk as { type?: string; isError?: boolean; errorSubtype?: string };
  return c?.type === 'result' && c.isError === true && c.errorSubtype === 'missing_assistant_message';
}

Try / catch

for await (const chunk of bridge) {
  if (isMissingAssistantResult(chunk)) {
    getLog().warn({}, 'pi_session_completed_without_output');
    throw new Error('Pi run ended with no assistant message; verify auth/network and retry');
  }
}

Prevention

When it happens

Trigger: A Pi session ends (agent_end) without any assistant message having been bridged: the model produced zero output before termination, the session errored immediately at startup, the run was aborted before the first assistant message, or assistant events were dropped by the transport.

Common situations: Pi provider crashed or was killed right after start; auth or network failure so no model call completed; prompt rejected before generation; event stream disconnected mid-run losing the assistant message event; Pi SDK version change altering event ordering.

Related errors


AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01). Data as JSON: /api/errors/a24f7f2a552ab446. Report an issue: GitHub.