Skip to content

Fix: Add production logging for StackOne utility tools - #24

Merged
ac-s1 merged 1 commit into
mainfrom
fix/production-logging-stackone-tools
Mar 25, 2026
Merged

ac-s1 merged 1 commit into
mainfrom
fix/production-logging-stackone-tools

Conversation

@ac-s1

@ac-s1 ac-s1 commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • logger.error and logger.warn were gated behind NODE_ENV=development, silencing all errors in production Vercel deployments
  • getStackOneUtilityToolsForAISDK() failures were completely invisible — returning {} with no trace, causing the agent to only use RAG tools
  • Added console.log/console.error at each step of the utility tool loading chain (fetchTools, utilityTools, getTool) so the exact failure point shows in Vercel runtime logs
  • Added hasActionTools check with a RAG-only fallback system prompt when action tools fail to load

Test plan

  • Merge and redeploy to Vercel
  • Send a chat message requesting a document action (e.g. "update the doc")
  • Check Vercel runtime logs for [Chat API], [Agent], and [StackOne tools] entries
  • Confirm logs show the exact failure point if action tools aren't loading

🤖 Generated with Claude Code


Summary by cubic

Fix silent production errors by enabling error/warn logging in prod and adding detailed runtime logs for StackOne tool loading. Adds a RAG-only fallback prompt when action tools aren’t available.

  • Bug Fixes

    • logger.error and logger.warn now log in production (were gated by NODE_ENV=development).
    • Errors from getStackOneUtilityToolsForAISDK() now surface instead of failing silently when tool_search/tool_execute are missing.
  • New Features

    • Added step-by-step logs for the StackOne tool load chain (fetchTools → utilityTools → getTool) and chat route context (account/integration counts, STACKONE_API_KEY presence).
    • Added hasActionTools check to switch to a RAG-only system prompt when action tools fail to load, with clear user messaging.

Written for commit 48ca0f0. Summary will update on new commits.

logger.error/warn were gated behind NODE_ENV=development, making all
errors from getStackOneUtilityToolsForAISDK invisible in production.
This caused silent failure when action tools (tool_search/tool_execute)
failed to load, with no trace in Vercel runtime logs.

- Make logger.error and logger.warn always log regardless of NODE_ENV
- Add console.log/error at each step of the utility tools loading chain
- Log full context (accountIds, integrations, API key presence) in chat route
- Add hasActionTools check with RAG-only fallback system prompt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
vercel Bot temporarily deployed to Preview – oauth-redirect-proxy March 25, 2026 17:24 Inactive
@vercel

vercel Bot commented Mar 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
oauth-redirect-proxy Ready Ready Preview, Comment Mar 25, 2026 5:31pm

Request Review

@ac-s1
ac-s1 merged commit 93a8cbe into main Mar 25, 2026
2 checks passed

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/rag-knowledge-agent/src/app/api/chat/route.ts">

<violation number="1" location="apps/rag-knowledge-agent/src/app/api/chat/route.ts:141">
P2: Avoid logging account ID prefixes in production logs; this leaks identifiable integration/account data.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

integrationIdsFromAgent: integrationIds.length,
integrationsFound: integrations.length,
accountIds: accountIds.length,
accountIdPreviews: accountIds.map(id => id.slice(0, 12) + '...'),

@cubic-dev-ai cubic-dev-ai Bot Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Avoid logging account ID prefixes in production logs; this leaks identifiable integration/account data.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/rag-knowledge-agent/src/app/api/chat/route.ts, line 141:

<comment>Avoid logging account ID prefixes in production logs; this leaks identifiable integration/account data.</comment>

<file context>
@@ -134,10 +134,14 @@ export async function POST(request: NextRequest) {
+            integrationIdsFromAgent: integrationIds.length,
+            integrationsFound: integrations.length,
             accountIds: accountIds.length,
+            accountIdPreviews: accountIds.map(id => id.slice(0, 12) + '...'),
+            documentIds: documentIds.length,
             documentContext: documentContext.length,
</file context>
Suggested change
accountIdPreviews: accountIds.map(id => id.slice(0, 12) + '...'),
hasAccountIds: accountIds.length > 0,
Fix with Cubic

This branch was previously deployed

1 inactive deployment
Preview – oauth-redirect-proxy — 48ca0f0f Deployed Mar 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants