Repository navigation
refactor(a365): centralize request context in the base scope - #243
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ccc29b9-bf5d-4725-be3b-c4276b233c4c
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ccc29b9-bf5d-4725-be3b-c4276b233c4c
03f9af7 to
b0718fe
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new tests do not cover a key that becomes scope-owned through a typed setter after creation.
Review effort: Balanced
Findings: 1
What changed in this PR
This PR makes A365 scope builders’ populated span attributes take precedence over later recordAttributes() calls.
Changes:
- Track keys populated by the span builder or typed setters, while leaving absent keys writable.
- Add precedence tests and a changelog entry.
| File | Description |
|---|---|
test/internal/unit/a365/scopes.test.ts |
Tests attribute precedence and generic writes. |
src/a365/scopes/OpenTelemetryScope.ts |
Tracks scope-owned keys and skips generic overwrites. |
CHANGELOG.md |
Documents the fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9834b6ca-9d85-4b99-aa3d-c346c03485d2
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9834b6ca-9d85-4b99-aa3d-c346c03485d2
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9834b6ca-9d85-4b99-aa3d-c346c03485d2
Jianbiao Lu (alexlu4250)
left a comment
There was a problem hiding this comment.
Looks good to me. Approving with a non blocking note from AI:
The PR intentionally keeps generic recordAttributes() as last-write-wins, which is the right design for the stated contract, but it means future callers can still overwrite builder and typed-setter values. That should be treated as a deliberate API behavior, not a bug; I’d keep it documented in the contract/tests, which the PR already does.

Summary
OpenTelemetryScopefor invoke-agent, inference, execute-tool, output, and guardrail spansoperationSource(service.name) consistently across scopesrecordAttributes(), including attributes initially set by the span builder or typed scope methodsCross-repository alignment
Notable behavior changes
Requestnow supports optionaloperationSourceOutputScopeandApplyGuardrailScopenow propagatesessionIdthrough the shared base mappingrecordAttributes()calls may overwrite base, builder, and typed-setter valuesValidation
npm test -- --run test/internal/unit/a365— 683 passednpm run buildnpm run lint— no errors (pre-existing warnings only)npm run formatgit diff --check