refactor: migrate logger calls to scoped context patterns#3067
refactor: migrate logger calls to scoped context patterns#3067amikofalvy merged 11 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
🦋 Changeset detectedLatest commit: 511a805 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
TL;DR — Migrates logger calls across the entire monorepo ( Key changes
Summary | 120 files | 11 commits | base: Scoped log context at execution entry points
Four entry points are wrapped:
Ambient field removal across run domain agents, tools, context, and routes
18 run-domain source files are updated. The three sub-patterns:
Ambient field removal across manage routes, evals, and middleware
One deliberate exception:
|
There was a problem hiding this comment.
Well-structured refactor that correctly wraps production code in runWithLogContext and updates 33 test mocks. The structural changes in all three production files are sound — no dropped code paths, all cleanup branches preserved. One actionable finding: conversationId is missing from the log context in two key functions.
Claude Opus | 𝕏
Ito Test Report ✅14 test cases ran. 7 additional findings, 7 passed. Overall, the unified run executed 14 test cases with a mixed result (7 passed, 7 failed): core CRUD/security/responsiveness paths were generally stable, but multiple medium/high-impact reliability defects were confirmed in production code. The most important issues were trigger-related correctness gaps (SSR/client timezone hydration mismatches plus unbounded Run Now duplicates and repeatable reruns), auth/contract failures (valid playground JWTs rejected and stale durable approvals incorrectly returning success), missing required bulk dataset-item creation UI despite backend support, and stale dataset-run deep links producing an internal 500 transport path instead of a clean not-found flow. ✅ Passed (7)ℹ️ Additional Findings (7)
|
…scoped logger context Remove repeated ambient fields (tenantId, projectId, agentId, requestId, conversationId) from logger calls in agentExecutionSteps, scheduledTriggerSteps, and executionHandler. Add runWithLogContext wrappers for operation-level context. Convert empty data objects to string-only logger calls. Update 33 test files to include runWithLogContext in their logger mocks so tests work with the new imports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… logger context Remove ambient fields (tenantId, projectId, agentId) from logger calls across 22 files in agent generation, tools, A2A, context resolution, routes, blob storage, and stream handling. Convert empty data objects to string-only calls. Fix global test setup mock to properly return mockLogger from with()/child(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com>
Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com>
…er context Remove ambient fields (tenantId, projectId, agentId) from logger calls across 41 files in manage routes, eval routes/services/workflows, and middleware. Convert empty data objects to string-only calls. Middleware files only get empty-object conversion (ambient fields kept since they run before ALS). Fix userId incorrectly removed from AgentMcpManager (not ambient). Update conversations-media test assertion for removed ambient fields. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Convert empty data objects to string-only logger calls across 5 files in data-access, dolt, utils. Conservative approach for library package: only empty-object cleanup, no ambient field removal since agents-core functions may be called outside ALS scope. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ntext
agents-sdk: Convert evaluationClient to use class member logger with
.with({ tenantId, projectId }) — removes 126 repeated field pairs.
agents-work-apps: Convert empty data objects to string-only logger calls
across 13 Slack and GitHub files. Conservative approach — no ambient
field removal since work-apps have their own middleware.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reset to main's version (which includes durable approval code) and re-applied runWithLogContext wrapper and ambient field removal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6aaf578 to
509cd92
Compare
…nflict Re-apply runWithLogContext wrappers and ambient field removal that was lost during the rebase conflict resolution. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f05896c to
82be302
Compare
Preview URLsUse 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
|
Remove agentId/tenantId/projectId from destructuring where they were only used in logger data objects that have been simplified. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Ito Test Report ✅20 test cases ran. 2 additional findings, 18 passed. Across 20 end-to-end, edge-case, and security scenarios, 18 passed and 2 failed, indicating strong overall regression stability across evaluations/datasets, trigger/webhook flows, GitHub/MCP settings, and auth/media/OAuth/Slack abuse defenses. The two key confirmed production defects were a medium-severity scheduled trigger creation failure when the default browser timezone is unsupported (e.g., Etc/Unknown) and a high-severity playground issue where refresh plus back/forward during active streaming leaves the chat pane/input unrecoverable, while duplicate-submit handling and other security checks remained fail-closed as expected. ✅ Passed (18)ℹ️ Additional Findings (2)
|
These files were modified by PRs #3062 and #3064 which merged after the logger migration in #3067 but were not updated to use the scoped context pattern. Wraps tool-approval.ts and tool-wrapper.ts execute paths in runWithLogContext({ toolCallId, toolName }), strips repeated ambient fields from individual logger calls, and adds logger scoped context guidance to AGENTS.md and the api-logging-guidelines skill. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>



































Summary
runWithLogContextwrappers for operation-level context (triggerId, invocationId, sessionId, etc.)logger.info({}, 'msg')tologger.info('msg')string-only form.with()pattern where classes repeat constructor fieldsMigration plan
See
specs/2026-04-06-logger-scoped-context/MIGRATION-PLAN.mdfor the full phased plan.Phases:
Test plan
runWithLogContext+with(33 files)pnpm checkpasses after each batch🤖 Generated with Claude Code