Skip to content

fix: concurrent-safe debug tracing with AsyncLocalStorage#18

Merged
jbreite merged 1 commit intomainfrom
fix/async-local-storage-debug-context
Feb 12, 2026
Merged

fix: concurrent-safe debug tracing with AsyncLocalStorage#18
jbreite merged 1 commit intomainfrom
fix/async-local-storage-debug-context

Conversation

@jbreite
Copy link
Copy Markdown
Owner

@jbreite jbreite commented Feb 12, 2026

Summary

  • Replace global mutable parentStack array with AsyncLocalStorage for debug parent tracking, fixing corrupted parent attribution when multiple Task tools run in parallel
  • Move debugEnd/debugError emission outside the parent context so the task's own end event renders at the correct indent level in human-readable output
  • Delete dead pushParent/popParent functions (not publicly exported, zero callers)
  • Add 54 unit tests for debug.ts (previously zero coverage), including parallel isolation regression tests
  • Bump to v0.5.2

…-safe debug tracing

The previous push/pop parent stack was a global mutable array shared
across all async contexts, causing corrupted parent attribution when
multiple Task tools run in parallel. Replace with AsyncLocalStorage
which gives each async continuation chain its own isolated context.

- Add runWithDebugParent() using AsyncLocalStorage for context propagation
- Move debugEnd/debugError outside parent context for correct indent level
- Remove deprecated pushParent/popParent (no callers, not publicly exported)
- Add 54 unit tests for debug module (previously zero coverage)
- Update AGENTS.md documentation
- Bump version to 0.5.2

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jbreite jbreite merged commit 0cd9292 into main Feb 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant