Skip to content

docs: add logger & scoped context (AsyncLocalStorage) guide#3079

Open
amikofalvy wants to merge 1 commit intomainfrom
claude/update-agents-logger-aG8f7
Open

docs: add logger & scoped context (AsyncLocalStorage) guide#3079
amikofalvy wants to merge 1 commit intomainfrom
claude/update-agents-logger-aG8f7

Conversation

@amikofalvy
Copy link
Copy Markdown
Collaborator

Summary

Added comprehensive documentation for the scoped context logger implementation built on Pino + AsyncLocalStorage in the AGENTS.md file.

Changes

  • Documentation added to AGENTS.md explaining the logger & scoped context system:
    • Overview of how request-level context (tenantId, projectId, agentId) is automatically included in logs
    • Key files involved in the implementation
    • Import patterns for both @inkeep/agents-core and agents-api
    • Three common usage patterns with code examples:
      1. Module-level logger (most common case)
      2. Class member logger with .with() for snapshot semantics
      3. Operation-level scoping with runWithLogContext()
    • Explanation of how the system works internally (middleware integration, ALS resolution, snapshot behavior, nesting support)
    • Clear rules and best practices for developers using the logger

Details

This documentation guide helps developers understand:

  • When and how to use getLogger() vs runWithLogContext()
  • The difference between dynamic ALS context resolution and snapshot semantics with .with()
  • Why certain patterns (like passing context manually or injecting loggers) should be avoided
  • How the middleware automatically sets up request-level context

https://claude.ai/code/session_01CCdgr1tjNzD9ZWj11zj8Qb

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

⚠️ No Changeset found

Latest commit: 2f72754

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agents-api Ready Ready Preview, Comment Apr 8, 2026 7:32pm
agents-docs Ready Ready Preview, Comment Apr 8, 2026 7:32pm
agents-manage-ui Ready Ready Preview, Comment Apr 8, 2026 7:32pm

Request Review

Document the AsyncLocalStorage-based scoped logger pattern introduced
in recent commits — imports, usage patterns, how it works, and rules.

https://claude.ai/code/session_01CCdgr1tjNzD9ZWj11zj8Qb
@amikofalvy amikofalvy force-pushed the claude/update-agents-logger-aG8f7 branch from 0796d00 to 2f72754 Compare April 8, 2026 19:29
@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog bot commented Apr 8, 2026

TL;DR — Adds a comprehensive "Logger & Scoped Context" section to AGENTS.md, documenting how the Pino + AsyncLocalStorage logger works, its import paths, usage patterns, and rules for AI coding agents and contributors.

Key changes

  • Add logger and scoped context documentation to AGENTS.md — New section under "Key Implementation Details" covering the PinoLogger / getLogger() / runWithLogContext() system, with import examples, three usage patterns (module-level, class member with .with(), operation-level scoping), an explanation of how ALS context flows through middleware, and a rules checklist.

Summary | 1 file | 1 commit | base: mainclaude/update-agents-logger-aG8f7

Before: No documented guidance on the logger system — agents and contributors had to read source code to understand getLogger(), runWithLogContext(), .with() semantics, and the rule against passing tenantId/projectId/agentId in individual log calls.
After: AGENTS.md includes a self-contained reference covering key files, imports, three usage patterns with code examples, how AsyncLocalStorage middleware propagates context, and explicit do/don't rules.

The new section sits between "Environment Configuration" and "Isolated Parallel Environments," giving it a natural place in the implementation details flow. It references the api-logging-guidelines skill for log-level guidance rather than duplicating that content.

AGENTS.md

Pullfrog  | View workflow run | Triggered by Pullfrog | Using Claude Opus𝕏

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, accurate documentation. All claims verified against the source code — PinoLogger, getLogger(), runWithLogContext(), .with() snapshot semantics, and AsyncLocalStorage usage all match the actual implementation in packages/agents-core/src/utils/logger.ts and related files. The section is well-placed, complements the existing api-logging-guidelines skill without overlap, and follows the established AGENTS.md structure.

Pullfrog  | View workflow run | Using Claude Opus𝕏

Copy link
Copy Markdown
Contributor

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary

(0) Total Issues | Risk: Low

Summary

This PR adds comprehensive documentation for the logger & scoped context system to AGENTS.md. The documentation:

  • Accurately describes the actual implementation in packages/agents-core/src/utils/logger.ts
  • Correctly references all key files (logger.ts, createApp.ts middleware)
  • Provides clear usage patterns with three well-documented approaches (module-level, class member with .with(), operation-level scoping)
  • Includes actionable rules that will help AI agents and contributors use the logger correctly
  • Cross-references the api-logging-guidelines skill appropriately for log level guidance

The section is well-placed between "Environment Configuration" and "Isolated Parallel Environments" in the AGENTS.md structure, following the established documentation patterns.


✅ APPROVE

Summary: Clean, accurate documentation that fills an important gap. All claims verified against source code — PinoLogger, getLogger(), runWithLogContext(), .with() snapshot semantics, and AsyncLocalStorage usage all match the actual implementation. The section complements the existing api-logging-guidelines skill without overlap. Ship it! 🚀

Reviewers (3)
Reviewer Returned Main Findings Consider While You're Here Inline Comments Pending Recs Discarded
pr-review-docs 0 0 0 0 0 0 0
pr-review-devops 0 0 0 0 0 0 0
pr-review-standards 0 0 0 0 0 0 0
Total 0 0 0 0 0 0 0

@github-actions github-actions bot deleted a comment from claude bot Apr 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Preview URLs

Use these stable preview aliases for testing this PR:

These point to the same Vercel preview deployment as the bot comment, but they stay stable and easier to find.

Raw Vercel deployment URLs

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity.
It will be closed in 7 days if no further activity occurs.

If this PR is still relevant:

  • Rebase it on the latest main branch
  • Add a comment explaining its current status
  • Request a review if it's ready

Thank you for your contributions!

@github-actions github-actions bot added the stale label Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants