Skip to content

[Bug]: Every delegate_task records two failed readCanonicalProjection spans #38082

Closed

Description

@mInrOz

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Run a server that exports traces over OTLP.
  2. In any thread, have the agent call the delegate_task MCP tool.
  3. Open the trace for that tools/call.

Expected behavior

A delegation that succeeds records no error spans.

Actual behavior

Every delegation records two failed ProjectionStore.readCanonicalProjection spans, each with a failed sql.transaction parent: No orchestration projection exists for thread <child thread id>. One sits inside Orchestrator.dispatchMessage, and the other runs straight under orchestrationV2.dispatch.delegatedTaskRequest. The task itself starts and finishes normally.

getProjectionWithPendingEvents in apps/server/src/orchestration-v2/Orchestrator.ts reads the stored projection under Effect.option before falling back to the pending thread.created event. The delegated child thread is created by the same command, so that read always misses. The traced getThreadRecords → readCanonicalProjection span has already ended as an error by the time Effect.option swallows the miss.

Same class of bug as #37763, which fixed the ProjectionStore.getThread span left by thread.create's id check.

Impact

Minor bug or occasional failure

Version or commit

main @ 6ef2c05

Environment

Linux, Node server with OTLP trace export; independent of provider.

Logs or stack traces

POST
└─ McpServer.@effect/mcp/2025-06-18/tools/call
   └─ OrchestratorMcpService.delegateTask
      └─ orchestrationV2.dispatch.withReceipt
         └─ orchestrationV2.dispatch.once
            └─ orchestrationV2.dispatch.delegatedTaskRequest
               ├─ Orchestrator.dispatchMessage
               │  └─ sql.transaction                          (error)
               │     └─ ProjectionStore.readCanonicalProjection (error: No orchestration projection exists for thread …)
               └─ sql.transaction                             (error)
                  └─ ProjectionStore.readCanonicalProjection  (error: No orchestration projection exists for thread …)

Workaround

None needed for users; it only adds error spans.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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