blog: one flag, every chunk — debug logging for TanStack AI#849
Conversation
Announce the new pluggable, category-toggleable debug logging system that ships with @tanstack/ai. Covers the one-flag default, the eight category toggles, piping into a custom Logger (pino etc.), the try/catch guarantee around user loggers, and the design calls behind emoji prefixes + console.dir(depth:null).
👷 Deploy request for tanstack pending review.Visit the deploys page to approve it
|
📝 WalkthroughWalkthroughA new blog post is added documenting debug logging capabilities for TanStack AI. The post covers enabling debug logging via configuration options across multiple activities ( Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/blog/debug-logging-for-tanstack-ai.md`:
- Line 13: Add a comma after the introductory phrase "Up until now" in the
sentence that begins "Up until now your options were limited." so it reads "Up
until now, your options were limited."—locate the sentence in the content block
(the line starting with "Up until now your options were limited.") and insert
the comma immediately after "now".
- Around line 35-42: The fenced code block showing the console output (the block
starting with the lines like "📤 [tanstack-ai:request] ..." and "🔧
[tanstack-ai:tools] ...") lacks a language specifier; update the opening fence
from ``` to a language such as ```text or ```console so the snippet
renders/accessibility is improved (e.g., change the opening fence to "```text"
while leaving the block contents unchanged).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4a5e08e5-f683-44e6-b8aa-0038385e9995
⛔ Files ignored due to path filters (1)
public/blog-assets/debug-logging-for-tanstack-ai/header.pngis excluded by!**/*.png
📒 Files selected for processing (1)
src/blog/debug-logging-for-tanstack-ai.md
|
|
||
| You kick off a `chat()` call. A chunk goes missing. A middleware you wrote last week doesn't seem to fire. A tool gets called with arguments you can't explain. Your stream finishes, the UI looks wrong, and you have no idea which layer lied to you. | ||
|
|
||
| Up until now your options were limited. You could wrap the SDK in a tracing platform, spend a day wiring OpenTelemetry, or sprinkle `console.log` into your own code and hope the problem lives where you can see it. Neither helps when the bug is **inside** the pipeline: a raw provider chunk that got dropped, a middleware that mutated config, a tool call the agent loop reissued. |
There was a problem hiding this comment.
Add comma after introductory phrase.
The sentence should read: "Up until now**,** your options were limited."
📝 Proposed fix
-Up until now your options were limited. You could wrap the SDK in a tracing platform, spend a day wiring OpenTelemetry, or sprinkle `console.log` into your own code and hope the problem lives where you can see it. Neither helps when the bug is **inside** the pipeline: a raw provider chunk that got dropped, a middleware that mutated config, a tool call the agent loop reissued.
+Up until now, your options were limited. You could wrap the SDK in a tracing platform, spend a day wiring OpenTelemetry, or sprinkle `console.log` into your own code and hope the problem lives where you can see it. Neither helps when the bug is **inside** the pipeline: a raw provider chunk that got dropped, a middleware that mutated config, a tool call the agent loop reissued.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Up until now your options were limited. You could wrap the SDK in a tracing platform, spend a day wiring OpenTelemetry, or sprinkle `console.log` into your own code and hope the problem lives where you can see it. Neither helps when the bug is **inside** the pipeline: a raw provider chunk that got dropped, a middleware that mutated config, a tool call the agent loop reissued. | |
| Up until now, your options were limited. You could wrap the SDK in a tracing platform, spend a day wiring OpenTelemetry, or sprinkle `console.log` into your own code and hope the problem lives where you can see it. Neither helps when the bug is **inside** the pipeline: a raw provider chunk that got dropped, a middleware that mutated config, a tool call the agent loop reissued. |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/blog/debug-logging-for-tanstack-ai.md` at line 13, Add a comma after the
introductory phrase "Up until now" in the sentence that begins "Up until now
your options were limited." so it reads "Up until now, your options were
limited."—locate the sentence in the content block (the line starting with "Up
until now your options were limited.") and insert the comma immediately after
"now".
| ``` | ||
| 📤 [tanstack-ai:request] 📤 activity=chat provider=openai model=gpt-4o messages=1 tools=0 stream=true | ||
| 🔁 [tanstack-ai:agentLoop] 🔁 run started | ||
| 📥 [tanstack-ai:provider] 📥 provider=openai type=response.output_text.delta | ||
| 📨 [tanstack-ai:output] 📨 type=TEXT_MESSAGE_CONTENT | ||
| 🧩 [tanstack-ai:middleware] 🧩 hook=onOutput | ||
| 🔧 [tanstack-ai:tools] 🔧 tool=getTodos phase=before | ||
| ``` |
There was a problem hiding this comment.
Add language specifier to fenced code block.
The console output example should specify a language (e.g., text or console) for proper rendering and accessibility.
📝 Proposed fix
-```
+```text
📤 [tanstack-ai:request] 📤 activity=chat provider=openai model=gpt-4o messages=1 tools=0 stream=true
🔁 [tanstack-ai:agentLoop] 🔁 run started
📥 [tanstack-ai:provider] 📥 provider=openai type=response.output_text.delta📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ``` | |
| 📤 [tanstack-ai:request] 📤 activity=chat provider=openai model=gpt-4o messages=1 tools=0 stream=true | |
| 🔁 [tanstack-ai:agentLoop] 🔁 run started | |
| 📥 [tanstack-ai:provider] 📥 provider=openai type=response.output_text.delta | |
| 📨 [tanstack-ai:output] 📨 type=TEXT_MESSAGE_CONTENT | |
| 🧩 [tanstack-ai:middleware] 🧩 hook=onOutput | |
| 🔧 [tanstack-ai:tools] 🔧 tool=getTodos phase=before | |
| ``` |
🧰 Tools
🪛 markdownlint-cli2 (0.22.0)
[warning] 35-35: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/blog/debug-logging-for-tanstack-ai.md` around lines 35 - 42, The fenced
code block showing the console output (the block starting with the lines like
"📤 [tanstack-ai:request] ..." and "🔧 [tanstack-ai:tools] ...") lacks a
language specifier; update the opening fence from ``` to a language such as
```text or ```console so the snippet renders/accessibility is improved (e.g.,
change the opening fence to "```text" while leaving the block contents
unchanged).
Summary
Adds a new blog post announcing the pluggable, category-toggleable debug logging system that just shipped in
@tanstack/ai(TanStack/ai#467).Post angle is the "anti-platform" story: one flag, zero infra, pipes into whatever logger you already have. It walks through:
debug: trueLogger(pino example)console.dir({ depth: null })Files
src/blog/debug-logging-for-tanstack-ai.md— the postpublic/blog-assets/debug-logging-for-tanstack-ai/header.png— header imageTest plan
/ai/latest/docs/advanced/debug-logging) resolvesSummary by CodeRabbit
debugoption, explore eight toggleable logging categories, and understand console and custom logger output options.