async-handler-pattern

Configure ClaudeOrchestrator handlers to return AwaitingLLM and complete via callbacks.

3|Updated Mar 17, 2026
One-click install
npx skills add https://github.com/transreal/claudecode --skill async-handler-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: async-handler-pattern
Source: https://github.com/transreal/claudecode/tree/main/Claude%20Directives/skills/async-handler-pattern
Command: npx skills add https://github.com/transreal/claudecode --skill async-handler-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents orchestration deadlocks and subtle race conditions when a Claude workflow transition handler must start an asynchronous LLM call and later complete via callback or engine timer.

Core Features & Use Cases

  • Correct AwaitingLLM orchestration flow: returns Status -> AwaitingLLM immediately, registers AwaitingLLMTransitions[awaitId], and completes via ClaudeCompleteHandlerOutput so the engine can safely produce tokens.
  • Safe dynamic binding in handlers: uses $ClaudeCurrentWid and $ClaudeCurrentAwaitId only within the awaiting handler, then copies values into a closure to avoid Missing["NotInHandler"] failures.
  • Timeouts, restore, and double-fire safety: configures AwaitingLLMTimeout / DefaultAwaitingLLMTimeout, re-installs timers after ClaudeSnapshotWorkflow + ClaudeRestoreWorkflow, and relies on silent discard when callback and timer fire out of order.
  • Diagnostics for real symptoms: resolves cases where workflows get stuck in AwaitingLLM, timeout firing stops working, snapshot restore never completes, or callback fires twice.
  • Observability compatibility: works with ClaudeOrchestrator_observability.wl so traceTransitions can show AwaitingLLM and handler logs include AwaitingLLM status.

Quick Start

Use this skill when your ClaudeOrchestrator handler mentions AwaitingLLM and your workflow gets stuck, times out incorrectly, or fails to complete after snapshot restore.

Frequently Asked Questions about async-handler-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does my Claude workflow get stuck in AwaitingLLM status and never complete?

Race conditions occur when callback and engine timer fire out of order during async LLM calls. This Skill relies on silent discard safety for double completion and ensures ClaudeCompleteHandlerOutput wraps payloads correctly to prevent orchestration deadlocks.

How do I fix ClaudeOrchestrator race conditions when an async LLM callback fires twice?

Race conditions occur when callback and engine timer fire out of order during async LLM calls. This Skill relies on silent discard safety for double completion and ensures ClaudeCompleteHandlerOutput wraps payloads correctly to prevent orchestration deadlocks.

How do I restore AwaitingLLM timers after a ClaudeSnapshotWorkflow and ClaudeRestoreWorkflow cycle?

Missing NotInHandler failures happen when $ClaudeCurrentWid and $ClaudeCurrentAwaitId are accessed outside the handler scope. This Skill copies these dynamic binding values into a closure within the awaiting handler to avoid scope resolution errors.

How do I prevent Missing NotInHandler failures when binding variables in Claude workflow handlers?

Missing NotInHandler failures happen when $ClaudeCurrentWid and $ClaudeCurrentAwaitId are accessed outside the handler scope. This Skill copies these dynamic binding values into a closure within the awaiting handler to avoid scope resolution errors.

Does ClaudeOrchestrator observability work with AwaitingLLM transition logging?

ClaudeOrchestrator_observability.wl integrates with AwaitingLLM flows so traceTransitions can display AwaitingLLM status. This Skill ensures handler logs include AwaitingLLM status for workflow debugging and orchestration diagnostics.