NestBot : Add structured tracing and timing logs for AI assistant execution pipeline
- Dominant language
- Python
- Stars
- 451
- Forks
- 702
- Avg merge
- 22h 59m
- Merged PRs (30d)
- 91
Description
**Is your feature request related to a problem? Please describe.**
Currently the NestBot AI assistant pipeline (router → agents → LLM → Slack response) works functionally, but it behaves like a “black box” from an operational perspective.
There is very limited observability into:
- how long routing takes
- which agent was selected
- how long LLM/agent execution takes
- total end-to-end response time
- which logs belong to which Slack message
When debugging issues such as slow responses, wrong intent classification, or failed replies, it is difficult to determine where the problem occurred (routing, agent execution, or Slack posting).
This makes troubleshooting and performance analysis harder in production environments.
**Describe the solution you'd like**
Add structured tracing and timing logs across the AI assistant execution pipeline.
Proposed improvements:
- Generate a request/trace ID per query
- Log step-level timings such as:
- routing time
- agent/LLM execution time
- total processing time
- Log selected intent, confidence, and chosen agent
- Include message/channel identifiers for easier correlation
- Keep logging lightweight and optional (debug/info level)
Target areas:
```
backend/apps/ai/router.py
backend/apps/ai/flows/assistant.py
backend/apps/slack/services/message_auto_reply.py
```
This will improve debugging, performance monitoring, and production reliability without changing existing behavior.
**Describe alternatives you've considered**
I considered adding only additional basic logs, but that still makes it difficult to correlate steps across the full pipeline.
A small structured tracing approach with consistent metadata (request ID + timings) would provide better visibility while keeping the implementation simple.
**Are you going to work on implementing this?**
- [x] Yes
- [ ] No
**Additional context**
This is not a functional change.
It is purely an observability and maintainability improvement to make the AI assistant easier to debug and operate as usage grows.
It is related to #2663
Contributor guide
Assessment
This issue has not been assessed yet.