今日已更新 31 条资讯 | 累计 29765 条内容
关于我们

Trace Any TypeScript Agent Framework With Adapters

Raju Dandigam 2026年08月09日 23:45 1 次阅读 来源:Dev.to

TypeScript teams rarely standardize on one AI framework forever. One service may use Vercel AI SDK, another LangChain.js, another OpenAI Agents SDK, and a mature system may call provider clients directly. Those implementations expose different callback, telemetry, and streaming surfaces. Observability becomes expensive when every dashboard, test rule, and CI report understands each framework independently. An adapter layer isolates that variation. Framework-specific code captures source events; the adapter translates them into one versioned trace model; the rest of the system operates on normalized events. framework callbacks or wrappers | v framework adapter | v versioned trace events | | | v v v local UI CI gates telemetry export The goal is not to pretend every framework is identical. The goal is to preserve a common set of observable facts without leaking framework details into every consumer. Put the Boundary in the Right Place A tempting interface is runWithTrace(input) -> { result, events } . It works in a demo but creates several problems: Streaming runs may not have one finite completion point. Buffering every event in memory does not scale. Callback-driven frameworks already own the run lifecycle. A framework may emit activity after the initial method returns. Returning events couples capture, storage, and application results. A stronger boundary translates source events as they arrive and sends normalized events to the tracing core. Define the Normalized Model First Keep the shared model small, explicit, and versioned. type SpanKind = ' run ' | ' model ' | ' tool ' | ' retrieval ' | ' decision ' ; type TraceEvent = | { schemaVersion : 1 ; event : ' span_started ' ; traceId : string ; spanId : string ; parentSpanId : string | null ; name : string ; kind : SpanKind ; timestamp : string ; attributes : Record < string , string | number | boolean > ; } | { schemaVersion : 1 ; event : ' span_ended ' ; traceId : string ; spanId : string ; timestamp : string ; st

本文内容来源于互联网,版权归原作者所有
查看原文