Conversation
The existing search tools only look up tickets by caller email, which cannot answer the question that matters before opening a new ticket: is somebody else already reporting this? A widespread issue gets reported by many different callers, so a caller-scoped search comes back empty and a duplicate gets created. find-similar-open-tickets searches by keyword across all callers, on both Incidents and User Requests at once, via their common abstract parent Ticket. It filters on operational_status, the only status attribute shared by every ticket class - Ticket itself has no detailed status field, so asking for one on the parent class would fail. finalclass keeps other Ticket subclasses (Problem, Change) out of the results. The tool returns candidates without scoring them: the server has no way to judge whether two tickets describe the same issue, so it hands the agent enough context (title, description, caller, dates) to decide. Keywords are sanitized before reaching the OQL so they cannot escape their string literal or turn into a match-everything pattern.
There was a problem hiding this comment.
Pull request overview
Adds cross-caller duplicate detection for open Incidents and User Requests.
Changes:
- Adds keyword-based Ticket search with optional type and result limit.
- Sanitizes OQL search terms.
- Adds request and TOON response templates.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/Tools/core/get/iTopGetTools.php |
Implements the MCP search tool and OQL construction. |
templates/findSimilarOpenTickets-input.json.twig |
Builds the iTop core/get request. |
templates/Ticket-output.toon.twig |
Formats matching tickets for the agent. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1
to
+3
| {% if json.objects === null %} | ||
| No open ticket matches these keywords in iTop. There is no apparent duplicate. | ||
| {% else %} |
Comment on lines
+161
to
+165
| default: | ||
| // Ticket is the abstract parent of Incident and UserRequest: querying it covers both | ||
| // classes at once. finalclass keeps other Ticket subclasses (Problem, Change...) out. | ||
| $class = 'Ticket'; | ||
| $classFilter = " AND finalclass IN ('Incident','UserRequest')"; |
Comment on lines
+185
to
+187
| $keyword = str_replace(["\\", "'", '"', '%', '_'], '', $keyword); | ||
| $keyword = preg_replace('/[\x00-\x1F\x7F]/u', '', $keyword); | ||
| return trim($keyword); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3
Problem
The existing ticket search tools are scoped to one caller's email. They cannot detect
that an issue has already been reported by someone else, so an agent has no way to check
for duplicates before creating a new Incident or User Request.
Solution
Adds
find-similar-open-tickets, a read-only tool that searches open Incidents and UserRequests by keyword, across all callers, via their common parent class
Ticket:operational_status(ongoing/resolved/closed), the only status attributeshared by every ticket class —
Ticketitself has no detailedstatusfield.finalclass IN ('Incident','UserRequest')soProblemandChangeare excluded.so it hands the agent enough context (title, description, caller, dates) to do so.
literal or turn into a match-everything (or match-almost-everything) pattern.
An optional
ticket_typeparameter restricts the search toIncidentorUserRequestalone, and
limitcaps the number of results.