-
-
Notifications
You must be signed in to change notification settings - Fork 42
feat: Add Context Observer and Log Analysis for build failures #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a proactive troubleshooting feature that automatically detects when users view failed build logs and offers AI-powered log analysis. The implementation includes a frontend context observer that monitors user behavior and a backend system that intelligently prioritizes user-provided logs over generic documentation.
Key Changes:
- Added a context-aware observer hook that detects console page visits and triggers a toast notification after users scroll to the bottom of build logs
- Implemented log pattern detection and parsing in the backend to separate log data from user queries, enabling specialized log analysis prompts
- Enhanced prompt engineering with a dedicated LOG_ANALYSIS_INSTRUCTION that prioritizes user logs over RAG-retrieved documentation
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/utils/useContextObserver.ts | Custom hook that monitors URL and scroll position to detect when users are viewing console logs |
| frontend/src/components/Toast.tsx | Proactive toast component offering log analysis assistance |
| frontend/src/components/Chatbot.tsx | Integration of observer and toast, with log scraping functionality to extract console output |
| frontend/src/styles/styles.ts | Styling definitions for the toast notification component |
| chatbot-core/api/services/chat_service.py | Log detection via regex pattern and separation of logs from queries for specialized handling |
| chatbot-core/api/prompts/prompts.py | New LOG_ANALYSIS_INSTRUCTION prompt for expert log analysis persona |
| chatbot-core/api/prompts/prompt_builder.py | Dynamic prompt switching based on presence of log context |
| chatbot-core/rag/embedding/bm25_indexer.py | Added if __name__ == "__main__" guard to prevent unintended execution during imports |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
There are some issues with this pr, so, I cannot merge this yet due to a Critical Security Blocker and an architectural concern regarding the RAG pipeline efficiency. Jenkins console logs are notorious for accidentally leaking secrets (API keys, passwords, internal IPs). Your PR currently scrapes the last 5,000 characters and sends them raw to the LLM. So, If a user has a line like Also, "With the new LOG_ANALYSIS_INSTRUCTION, the Bot correctly ignored the irrelevant documentation." This implies that we are still performing a Vector Search using the 5,000 characters of logs as the query, but simply telling the LLM to ignore the bad results. Searching FAISS with a 5,000-char stack trace is computationally expensive and yields "garbage" results (noise).
|
|
Update: I have addressed the feedback with two key improvements:
Ready for review! |
|
I have one question regarding the new Error Signature step: "extract a concise 'error signature'... from logs using the LLM" Does this introduce a noticeable latency penalty? (i.e., Are we doing a full LLM round-trip just to get the search query before generating the final answer?)
So, Please post a quick "Before vs. After" timing benchmark (e.g., "Old: 2.5s -> New: 3.2s"). If the added delay is under 1-2 seconds, I think the accuracy gain is worth it. |
Valid point regarding the latency. Clarification: The "Error Signature" step does introduce a full LLM round-trip. On my local development machine (CPU-only laptop), this is noticeable, but it scales significantly better with proper hardware. Benchmark (Local CPU-only Environment): Penalty Added: ~41s (Time for the extra LLM inference step) Total Latency: ~135s (vs ~95s baseline for standard queries) Interpretation: While ~41s is blocking on a laptop CPU, this purely reflects the inference speed of the local model for that specific prompt. On a production setup with a GPU (or using a faster provider), this extra step would likely add only 1–2 seconds. Given that the previous Regex-only approach often failed on complex or unstructured stack traces (leading to "garbage-in, garbage-out" retrieval), I believe the accuracy gain is worth the latency trade-off. |
|
a +41s penalty (bringing total wait time to ~2 mins on CPU) is a UX risk. Users might think the plugin has crashed. So, do these,
|
|
Agreed, a ~2 min wait on CPU is definitely a bad user experience; users will assume it hung.
Quick Question: Working on the UX changes now! |
|
Yes, absolutely. Since adding the Log Analysis logic likely pushed |
|
I'm kinda occupied, give me some time to review. |
berviantoleo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing isLoading to loadingStatus is not necessary for some components.
Please keep the isLoading and pass the loadingStatus only for the required components.
We can minimize the changes with it.
…atbot-plugin into feature/context-aware-UI
ae6b737 to
8bb7709
Compare
I've addressed the feedback from the review:
All tests have been updated to reflect these changes and are passing. |
|
hey! @cnu1812 I have done the changes asked by @berviantoleo, please review this. |


Title: feat: Add Context Observer & Proactive Log Analysis for Build Failures
This PR introduces a "Proactive Troubleshooting" feature that detects when a user is viewing a failed build log and offers immediate AI analysis. It also includes backend optimizations to ensure the LLM prioritizes user logs over generic documentation.
Key Changes:
1. Frontend (Context Observer):
useContextObserverthat monitors the URL (checking for/console) and scroll position.ProactiveToastcomponent that appears non-intrusively when a user pauses at the bottom of a build log..console-outputelement to provide context to the LLM.2. Backend (Log Analysis Logic):
chat_service.pywith a Regex pattern to detect when a message contains scraped logs.LOG_ANALYSIS_INSTRUCTIONinprompts.py.prompt_builder.pyto dynamically switch system instructions. If raw logs are detected, the system switches to an "Expert Debugger" persona that strictly prioritizes user logs over retrieved RAG documentation, preventing hallucinations based on irrelevant context.Testing done
Manual Integration Testing:
I created a test Jenkins job (
test-fail-job) configured to execute a batch commandexit 1to simulate a failure.exit 1error.LOG_ANALYSIS_INSTRUCTION, the Bot correctly ignored the irrelevant documentation and identified the specific batch failure from the provided logs.Fixes Issue #77
Screenshots:


Submitter checklist