Repository navigation
feat(observability): use Effect AI Telemetry for model and tool spans - #57
Merged
Merged
Conversation
Compose `Telemetry.CurrentSpanTransformer` around each model call, running a host-provided transformer first, so model spans keep Effect AI's span name and the library identity is written through `addGenAIAnnotations` and `addSpanAttributes`. Build tool attributes once and apply the same map to the canonical Tool span and its terminal log, dropping duplicated unprefixed keys.
The package exports check requires `Effect.withSpan` at an allowlisted operation boundary. Create each `execute_tool` span at its call site and let a separate helper annotate the current span through `addSpanAttributes`, so the shared attribute map still reaches the Tool span.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Routes model and Tool telemetry through the pinned
effect/ai/Telemetryprimitives.Telemetry.CurrentSpanTransformer: a host-provided transformer runs first, then the library identity (gen_ai.agent.*,gen_ai.conversation.id,effect_agent.run,effect_agent.thread,effect_agent.turn), written withaddGenAIAnnotationsandaddSpanAttributes. Thechat <model>span rename and the customTracerare gone, so model spans keep Effect AI'sLanguageModel.streamTextname.addSpanAttributesto the canonical Tool span; the same map is annotated on the terminal Tool log.effect_agent.tool.parent_call.idremains.BEHAVIOR CHANGE: consumers reading
chat <model>spans or the unprefixedagentId,threadId,runId,turnId,toolCallId,toolName,parentToolCallId,sequenceIndex,toolExecutionClass, ortoolOutcomeattributes should read thegen_ai.*andeffect_agent.*equivalents.Checks run on this head:
pnpm typecheck— exit 0, 0 errorspnpm lint— 0 warnings, 0 errorspnpm format:check— cleanpnpm build— exit 0pnpm --filter @systemfsoftware/agent test— 39 files, 161 tests passed