Skip to content

Add logging for tool execution and error handling in RequestInfoFromTableWithAIUseCaseV7#1638

Merged
Artuomka merged 1 commit into
mainfrom
backend_logging_ai_insights
Feb 26, 2026
Merged

Add logging for tool execution and error handling in RequestInfoFromTableWithAIUseCaseV7#1638
Artuomka merged 1 commit into
mainfrom
backend_logging_ai_insights

Conversation

@Artuomka

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings February 26, 2026 15:05
@Artuomka Artuomka enabled auto-merge February 26, 2026 15:05

Copilot AI 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.

Pull request overview

Adds request-scoped logging to the AI “tool loop” in RequestInfoFromTableWithAIUseCaseV7 to improve observability around tool execution and error cases.

Changes:

  • Introduces a NestJS Logger instance on the use case.
  • Logs tool-loop iterations, tool calls, tool results, and loop/tool-call errors (plus a max-depth warning).
  • Minor formatting cleanup in the chat name generation prompt string.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +198 to +199
this.logger.log(
`Tool call: ${toolCall.name}, arguments=${JSON.stringify(toolCall.arguments)}`,

Copilot AI Feb 26, 2026

Copy link

Choose a reason for hiding this comment

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

Logging full toolCall.arguments can leak sensitive data (e.g., raw SQL queries / Mongo pipelines, user-provided values) into application logs and may also create very large log lines. Consider logging only safe metadata (tool name/id, argument keys, and/or argument lengths) and/or truncating/redacting values, ideally at debug/verbose level behind a feature flag.

Suggested change
this.logger.log(
`Tool call: ${toolCall.name}, arguments=${JSON.stringify(toolCall.arguments)}`,
const argumentKeys =
toolCall.arguments && typeof toolCall.arguments === 'object'
? Object.keys(toolCall.arguments)
: [];
const argumentLength = JSON.stringify(toolCall.arguments ?? '').length;
this.logger.log(
`Tool call: ${toolCall.name}, argumentKeys=${argumentKeys.join(',')}, argumentLength=${argumentLength}`,

Copilot uses AI. Check for mistakes.
@Artuomka Artuomka merged commit 2eafa04 into main Feb 26, 2026
21 of 23 checks passed
@Artuomka Artuomka deleted the backend_logging_ai_insights branch February 26, 2026 15:18
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