Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
67e43cd
feat: initial pass of cloudflare-native ai tracing
mattzcarey Jul 2, 2026
de59c88
feat: add ai sdk v7 telemetry support to ai-tracing
mattzcarey Jul 2, 2026
e57d86b
chore: align ai-tracing with repo conventions
mattzcarey Jul 2, 2026
ad2af3b
refactor: fold ai tracing into agents observability exports
mattzcarey Jul 2, 2026
5aebb07
feat: align tracing schema with OTel GenAI semconv, harden public sur…
mattzcarey Jul 3, 2026
1d46f72
feat: instrument think out of the box
mattzcarey Jul 3, 2026
4ec1c34
fix: address external code review of the tracing wrapper
mattzcarey Jul 3, 2026
384c005
fix: address round-2 review findings
mattzcarey Jul 3, 2026
5f0619f
fix: forward early termination to streaming tool iterators
mattzcarey Jul 3, 2026
6d98e50
fix(observability): keep tracing adapter internal
mattzcarey Jul 8, 2026
4d1b3b2
refactor(observability): trim tracing surface
mattzcarey Jul 8, 2026
ed800a6
fix(observability): correct AI trace semantics
mattzcarey Jul 8, 2026
4abb770
fix(observability): retain span name limit
mattzcarey Jul 8, 2026
c584f28
docs(observability): remove repeated scope section
mattzcarey Jul 8, 2026
3d0d653
refactor(observability): scope AI tracing to SDK v6
mattzcarey Jul 8, 2026
86ad301
feat: wrap agent initialization in tracing span
Ankcorn Jul 13, 2026
58f1cc3
feat(observability): restore AI SDK v7 telemetry integration
mattzcarey Jul 13, 2026
25ae8fd
feat(observability): opt-in span content capture
mattzcarey Jul 14, 2026
cf12a14
refactor(observability): match AI SDK recordInputs/recordOutputs in T…
mattzcarey Jul 14, 2026
b8ef708
docs(observability): clarify system-role message + per-turn override …
mattzcarey Jul 14, 2026
ee1a3e4
fix(observability): record message content on chat spans
mattzcarey Jul 14, 2026
694b902
feat(observability): trace tool approval lifecycle
mattzcarey Jul 14, 2026
dc75e42
fix(think): run durable submissions from alarm invocations
mattzcarey Jul 14, 2026
4aa93b1
feat(observability): reference AI Gateway logs
mattzcarey Jul 14, 2026
0ec82a1
fix(observability): restore opt-in GenAI payloads
mattzcarey Jul 15, 2026
cdb0a21
feat(observability): group agent storage spans
Ankcorn Jul 15, 2026
95b6b8f
fix(observability): conform stored messages to GenAI schemas
mattzcarey Jul 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/agent-initialization-span.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"agents": minor
"@cloudflare/ai-chat": patch
"@cloudflare/think": patch
---

Group SDK-managed initialization, startup, chat interactions, turns, and durable submissions into semantic phases. Storage-heavy setup, hydration, recovery, request persistence, and response persistence each receive a named bucket, keeping inference and tool spans visible without discarding lower-level Durable Object SQLite spans. Each span records agent identity, storage phase, a stable marker for UI grouping, and operation-specific metadata. No-op on runtimes without the `tracing` API.
5 changes: 5 additions & 0 deletions .changeset/agents-observability-ai-tracing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"agents": minor
---

Add `agents/observability/ai` with `wrapAISDK` for AI SDK v6 and `createAISDKTelemetry` for AI SDK v7. Both project Cloudflare-native `invoke_agent {agent}`, `chat {model}`, and `execute_tool {tool}` spans using scalar OpenTelemetry GenAI attributes, including request settings, token usage, finish reasons, tool-call IDs, model-call time to first chunk, bounded AI SDK v6 approval lifecycle spans, and conditional AI Gateway log references. Payload storage is opt-in: `storeMessages` writes OTel-schema input/output message arrays to `chat` (`{ role, parts }`, canonical text/reasoning/tool parts, and output `finish_reason`; oldest messages are dropped past the budget while protecting the first two), and `storeTools` writes arguments/results to `execute_tool`. The flags themselves are never emitted as span attributes. Schemas, request headers, provider options, and raw errors remain excluded.
5 changes: 5 additions & 0 deletions .changeset/think-alarm-owned-submissions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/think": patch
---

Run durable submissions only from their awaited scheduled drain, preventing model work and tracing spans from outliving the short submission-acceptance invocation.
5 changes: 5 additions & 0 deletions .changeset/think-out-of-box-tracing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/think": minor
---

Think agents emit Cloudflare-native traces out of the box with no tracing setup beyond enabling Worker traces. Named lifecycle and storage-phase spans group Durable Object internals around startup, request persistence, turn preparation, inference, result persistence, recovery, alarms, and durable submissions. Every inference call produces an `invoke_agent {agent class}` span with `chat {model}` and `execute_tool {tool}` children. Think supplies durable identity and turn metadata. Payload storage remains off by default; agents can set `storeMessages` for OTel-schema model messages (`{ role, parts }`, canonical tool parts, and output `finish_reason`) on `chat` and `storeTools` for tool arguments/results on `execute_tool`. These flags configure the wrapper and are never emitted as metadata or attributes. Model streams are finalized on early exit, and durable submissions run from their awaited alarm invocation so spans do not outlive invocation boundaries.
11 changes: 7 additions & 4 deletions design/think-durable-submissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,13 @@ avoid unsafe replay:

1. `submitMessages()` serializes and sanitizes the messages, inserts a
`pending` row, emits `submission:create`, emits the initial `pending` status,
schedules an idempotent `_drainThinkSubmissions` alarm, and starts an
in-memory drain.
2. `_drainSubmissions()` claims the oldest `pending` row by conditionally
updating it to `running`.
and schedules an idempotent `_drainThinkSubmissions` alarm. It does not start
model work inside the short acceptance invocation.
2. The awaited `_drainThinkSubmissions` alarm owns `_drainSubmissions()`, which
claims the oldest `pending` row by conditionally updating it to `running`.
Keeping execution inside that alarm invocation also gives tracing spans the
correct lifecycle owner; no `invoke_agent` span crosses an invocation
boundary.
3. `_runSubmission()` calls the same programmatic turn path used by
`saveMessages()`, with the submission id as the request id.
4. `_runProgrammaticMessagesTurn()` appends submitted messages to Session,
Expand Down
282 changes: 282 additions & 0 deletions docs/agents/observability.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions packages/agents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@
"import": "./dist/observability/index.js",
"require": "./dist/observability/index.js"
},
"./observability/ai": {
"types": "./dist/observability/ai/index.d.ts",
"import": "./dist/observability/ai/index.js",
"require": "./dist/observability/ai/index.js"
},
"./react": {
"types": "./dist/react.d.ts",
"import": "./dist/react.js",
Expand Down
1 change: 1 addition & 0 deletions packages/agents/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const entries = [
"src/mcp/do-oauth-client-provider.ts",
"src/mcp/x402.ts",
"src/observability/index.ts",
"src/observability/ai/index.ts",
"src/codemode/ai.ts",
"src/experimental/memory/session/index.ts",
"src/experimental/memory/utils/index.ts",
Expand Down
Loading
Loading