API Reference
rcpond: A tool to partly automate RCP requests
auth
OAuth 2.0 Authorization Code + PKCE authentication for rcpond.
Provides the following public functions:
get_bearer_token(config): Return a valid Bearer token string for the ServiceNow API, running the full browser-based flow or a silent token refresh as needed.get_id_token(): Return theid_tokenJWT from the cached token response, orNoneif absent (requiresopenidscope).clear_token_cache(): Delete any cached tokens.
Token lifecycle
- If a cached token exists and is not expired, it is returned immediately.
- If the access token is expired but a refresh token is present, a silent refresh is attempted. On success the new token is cached and returned.
- If no usable cache is present (or refresh fails), the Authorization Code
- PKCE flow is launched: the user's browser is opened at the ServiceNow
authorisation URL, a local loopback server on
localhost:<port>captures the redirect, and the code is exchanged for tokens.
Token cache
Tokens are stored at $XDG_CACHE_HOME/rcpond/tokens.json with mode
0o600 (owner-readable only).
No configuration is required beyond the Config object.
clear_token_cache()
Delete any cached OAuth tokens.
Source code in rcpond/auth.py
91 92 93 94 95 | |
get_bearer_token(config)
Return a valid Bearer token for the ServiceNow API.
Reads from the token cache, refreshes silently if possible, and falls back to the full browser-based Authorization Code + PKCE flow when needed.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in rcpond/auth.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
get_id_token()
Return the id_token from the cached OAuth token response, or None if absent.
Requires the openid scope to have been requested during authentication.
Source code in rcpond/auth.py
82 83 84 85 86 87 88 | |
cli
CLI for rcpond.
This module creates the Typer cli object that is the target of the pyproject.scripts directive.
It adds the following subcommands
loginwhoamidisplay-alldisplay-ticketbrowse-ticketprocess-nextprocess-ticketprocess-allevaluate-all
Each delegating to the corresponding function in command.py.
Configuration is supplied via group-level options (e.g. --env-file) that
must appear before the subcommand name:
rcpond --env-file .env display-all-tickets
All config options default to None and fall back to RCPOND_* environment
variables and/or any .env file supplied.
The Config object is constructed via the _config helpful func, so that config validation will not be called when using the --help option, directly on rcpond or one one of the subcommands.
browse_ticket(ctx, ticket_number)
Opens a ticket in your default the browser (e.g. RES0001234).
Source code in rcpond/cli.py
148 149 150 151 152 153 | |
display_all(ctx, long_list=False)
Display all unassigned tickets from ServiceNow.
Source code in rcpond/cli.py
136 137 138 139 | |
display_ticket(ctx, ticket_number)
Display the details of a specific ticket (e.g. RES0001234).
Source code in rcpond/cli.py
142 143 144 145 | |
evaluate_all(ctx, in_dir, out_dir, num_runs=1)
Evaluate LLM performance against a directory of pre-downloaded HTML tickets.
The output filename is derived from the configured LLM model name and the
number of runs, e.g. gpt-4o_3runs.json.
Source code in rcpond/cli.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
login(ctx)
Authorise rcpond with ServiceNow via OAuth (browser-based flow).
Opens a browser, completes the Authorization Code + PKCE flow, and caches the resulting tokens. Subsequent commands will use the cached token automatically without prompting again.
Source code in rcpond/cli.py
104 105 106 107 108 109 110 111 112 113 114 115 | |
process_all(ctx, dry_run=False, reply_mode=ReplyMode.default, yes_i_am_sure=False)
Review all unassigned tickets via the LLM.
Source code in rcpond/cli.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
process_next(ctx, dry_run=False, reply_mode=ReplyMode.default)
Review an arbitrarily selected unassigned ticket via the LLM.
Source code in rcpond/cli.py
164 165 166 167 168 169 170 171 | |
process_ticket(ctx, ticket_number, dry_run=False, reply_mode=ReplyMode.default)
Review a specific ticket (e.g. RES0001234) via the LLM.
Source code in rcpond/cli.py
174 175 176 177 178 179 180 181 182 183 184 | |
whoami(ctx)
Show the identity of the currently authenticated OAuth user.
Source code in rcpond/cli.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
command
High-level commands for rcpond: listing, processing, and batch-processing tickets.
The four main entry points are:
display_all_tickets: List unassigned tickets from ServiceNow.process_next_ticket: Review one arbitrarily chosen ticket via the LLM.process_specific_ticket: Review a given ticket via the LLM.batch_process_tickets: Review all unassigned tickets via the LLM.batch_evaluate_tickets: Evaluate LLM performance against pre-downloaded HTML tickets. Requires thehtmloptional dependency group (pip install rcpond[html]).
ReplyMode
Bases: str, Enum
Controls which tickets _process_ticket will skip.
cautious: skip if RCPond has ever posted on the ticket. default: skip only when RCPond's comment or work note is the most recent activity. always: never skip regardless of ticket state.
Source code in rcpond/command.py
25 26 27 28 29 30 31 32 33 34 35 | |
batch_evaluate_tickets(in_dir, out_file, num_runs=1, config=None)
Process all Azure tickets in an offline HTML directory, across multiple runs.
Used for evaluating the performance of the LLM in reviewing tickets. Results
are written as dict[str, list[LLMResponse]] keyed by ticket number, so
that each ticket's responses across all runs are grouped together. Non-Azure
tickets are skipped.
| Parameters: |
|
|---|
Source code in rcpond/command.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
batch_process_tickets(dry_run, reply_mode, config=None)
Process all unassigned ServiceNow tickets via the LLM.
Each ticket is reviewed individually. The LLM response and reasoning are
displayed for each. If the LLM recommends actions and dry_run is False,
the actions are performed.
| Parameters: |
|---|
Source code in rcpond/command.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
display_all_tickets(long_list, config=None)
Display the list of unassigned tickets from ServiceNow to the user.
Source code in rcpond/command.py
117 118 119 120 121 | |
display_single_ticket(ticket_number, config=None)
Display the details of a specific ticket.
Source code in rcpond/command.py
124 125 126 127 128 129 | |
get_ticket_url(ticket_number, config=None)
Return the ServiceNow Web UI URL for a specific ticket.
| Parameters: |
|
|---|
Source code in rcpond/command.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
process_next_ticket(dry_run, reply_mode, config=None)
Process an arbitrarily selected ServiceNow ticket via the LLM.
The LLM response and reasoning are displayed to the user. If the LLM
recommends an action and dry_run is False, the action is performed.
| Parameters: |
|---|
Source code in rcpond/command.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
process_specific_ticket(ticket_number, dry_run, reply_mode, config=None)
Process the given ServiceNow ticket via the LLM.
The LLM response and reasoning are displayed to the user. If the LLM
recommends an action and dry_run is False, the action is performed.
| Parameters: |
|
|---|
Source code in rcpond/command.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
config
Configuration loading and validation for rcpond.
Provides class Config to read, parse, and make available
configuration variables required at runtime. The constructor loads
configuration from up to three sources, in order of increasing precedence:
- Exactly one config file — either
$XDG_CONFIG_HOME/rcpond/default.config(the personal default) or the file given byenv_path, but never both. Supplyingenv_pathcompletely replaces the XDG file; the XDG file is not read at all and any values it contains are ignored. - Environment variables prefixed with
RCPOND_and uppercased (e.g.RCPOND_LLM_MODEL) - Explicit CLI arguments passed as
cli_args
Values from a later source override earlier ones. A ValueError
is raised if any required field is still missing after all sources are
merged, or if a path field does not exist on disk.
The constructor implements some basic validation of parameters, specifically ensuring that the file paths are valid.
File format
The format of the configuration file is:
RCPOND_LLM_CHAT_COMPLETIONS_URL=...
RCPOND_LLM_API_KEY=your-api-key-here
RCPOND_LLM_MODEL=...
RCPOND_SERVICENOW_URL=https://turing-api.azure-api.net/dev-research/api/now/table
RCPOND_SERVICENOW_WEB_URL=https://alanturingdev.service-now.com
RCPOND_RULES_PATH=/path/to/rule/file
RCPOND_SYSTEM_PROMPT_TEMPLATE_PATH=/path/to/prompt/file
# Static token auth (required unless OAuth credentials are set):
RCPOND_SERVICENOW_TOKEN=your-servicenow-token # pragma: allowlist secret
# OAuth auth (takes precedence over the static token when both are set):
# RCPOND_SERVICENOW_CLIENT_ID=your-client-id
# RCPOND_SERVICENOW_CLIENT_SECRET=your-client-secret
# RCPOND_SERVICENOW_OAUTH_SCOPE=useraccount
# RCPOND_SERVICENOW_OAUTH_REDIRECT_PORT=8765
# RCPOND_SERVICENOW_OAUTH_AUTH_URL=https://alanturingdev.service-now.com/oauth_auth.do
# RCPOND_SERVICENOW_OAUTH_TOKEN_URL=https://alanturingdev.service-now.com/oauth_token.do
Example use
the_config = Config("/home/.config/rcpond/rcpond.txt") the_config.servicenow_token
Config
dataclass
Validated runtime configuration for rcpond.
| Parameters: |
|
|---|
| Attributes: |
|
|---|
Source code in rcpond/config.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
display
Display functions for rcpond output.
Provides:
display_all_tickets: Display a grouped summary table of tickets.display_short_ticket: Display a high-level ticket summary.display_full_ticket: Display the full details of a ticket.display_response: Display an LLM response.
display_full_ticket(ticket, *, console=None)
Display the full details of a ticket using Rich formatting.
| Parameters: |
|
|---|
Source code in rcpond/display.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
display_multi_tickets(tickets, *, console=None)
Display a table of ticket summaries.
Each section represents tickets with common values of "Category" and "Description". The Description field is used for the section title.
Each row represents a single ticket. It should have the columns - Number - Opened date/time - Requested by - Status (new / assigned / on-hold / etc)
Source code in rcpond/display.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
display_response(response, *, console=None)
Display an LLM response.
| Parameters: |
|
|---|
Source code in rcpond/display.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
display_short_ticket(ticket, *, console=None)
Display a high-level ticket summary.
| Parameters: |
|
|---|
Source code in rcpond/display.py
82 83 84 85 86 87 88 89 90 91 92 93 | |
html_servicenow
A read-only ServiceNow interface backed by pre-downloaded HTML files.
Provides HtmlServiceNow, a subclass of ServiceNow that reads ticket
data from a directory of HTML export files (produced by the
/x_tati_resmgt_research.do?... endpoint) instead of making live API calls.
Public API
HtmlServiceNow(html_dir): Construct from a directory of*.htmlfiles.- All read methods from
ServiceNoware supported:get_tickets(),get_ticket(),get_full_ticket(),get_work_notes(). - Write methods (
post_note(),assign_to()) are no-ops. get_assignee()returns an empty assignee dict — assignment state is not stored in the HTML export.
Return types
Same as ServiceNow: list[Ticket], Ticket, FullTicket, list[str].
Configuration
No Config object is needed. Pass the directory path directly.
HtmlServiceNow
Bases: ServiceNow
Read-only ServiceNow interface backed by a directory of HTML export files.
sn = HtmlServiceNow(Path("downloads/")) sn.get_tickets()
Source code in rcpond/html_servicenow.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
assign_to(_ticket, _assignee)
No-op — HTML source is read-only. Returns an empty assignee dict.
Source code in rcpond/html_servicenow.py
186 187 188 | |
get_assignee(tkt)
Return the assignee for tkt extracted from the HTML.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in rcpond/html_servicenow.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
get_full_ticket(tkt)
Return a FullTicket for tkt.
If tkt is already a FullTicket (as returned by get_tickets),
it is returned directly. Otherwise the HTML file is parsed.
| Parameters: |
|
|---|
| Returns: |
|---|
Source code in rcpond/html_servicenow.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
get_tickets(long_list=False)
Return a FullTicket for each HTML file in html_dir.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in rcpond/html_servicenow.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
get_work_notes(tkt)
Return the work notes for tkt extracted from the HTML activity log.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in rcpond/html_servicenow.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
post_note(_tkt, _note)
No-op — HTML source is read-only.
Source code in rcpond/html_servicenow.py
180 181 | |
llm
An interface to an OpenAI-compatible chat completions API.
Provides a class, LLM, which wraps the chat completions endpoint.
The only function is:
LLM.generate(): To generate a response given a system prompt and a user prompt, optionally with tool definitions.
Responses are returned as instances of an LLMResponse dataclass
containing the response text, optional reasoning content, and any
planned tool call.
The chat completions URL and API key are supplied via a Config
object.
LLM
Simple wrapper around an OpenAI-compatible chat completions API.
Example:
llm = LLM(config) response = llm.generate("You are helpful.", "Hello!", model="gpt-4")
Source code in rcpond/llm.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
__init__(config)
Initialise the LLM class.
| Parameters: |
|
|---|
Source code in rcpond/llm.py
56 57 58 59 60 61 62 63 64 65 | |
generate(system_prompt, user_prompt, model, tools=None, ticket_number=None)
Generate an LLM response given a system prompt and a user prompt.
Formats the system and user prompt into a single prompt and calls the _generate method to get the response from the LLM.
LLM response is parsed into LLMResponse dataclass.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in rcpond/llm.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
LLMResponse
dataclass
The parsed response from an LLM chat completion.
Source code in rcpond/llm.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
llm_model = None
class-attribute
instance-attribute
The model identifier used to generate this response. A value None indiciates that the response was not LLM generated, but generated deterministically.
planned_tool_call = None
class-attribute
instance-attribute
Optional tool call requested by the model, with arguments parsed from JSON.
reasoning = None
class-attribute
instance-attribute
Optional reasoning content (e.g. from models that support chain-of-thought).
response_text
instance-attribute
The text content of the response.
ticket_number = None
class-attribute
instance-attribute
The ticket number this response relates to, passed in by the caller.
parse_html
Parse ServiceNow ticket HTML export files.
Provides two public functions:
extract_key_facts(filename): Parse a ServiceNow ticket HTML file and return a dict of extracted fields.parse_ticket_html(filename): Parse a ServiceNow ticket HTML file and return aFullTicketinstance.
The HTML files are generated by the ServiceNow export endpoint::
/x_tati_resmgt_research.do?sys_id={sys_id}&sysparm_view=Export_to_pdf&...
Return types
extract_key_facts returns a dict[str, str | pd.DataFrame | None].
String fields are None when the corresponding element is absent from the HTML.
The "activities" key always holds a pd.DataFrame (empty if no activities
are found).
parse_ticket_html returns a FullTicket.
No configuration is required.
extract_key_facts(filename)
Extract ticket fields from a ServiceNow HTML export file.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in rcpond/parse_html.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
parse_ticket_html(filename)
Parse a ServiceNow ticket HTML export file and return a FullTicket.
| Parameters: |
|
|---|
| Returns: |
|---|
Source code in rcpond/parse_html.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
prompt
Prompt construction for rcpond, including reading RULES.md and formatting ticket data.
Provides a single public function:
construct_prompt: Builds the (system_prompt, user_prompt) pair for the LLM given a full ticket and config.
The system prompt is formed by reading the rules file and rendering it into a template using Python's str.format. The user prompt is the full ticket serialised as JSON.
construct_prompt(full_ticket, config)
Construct the system and user prompts for the LLM given a full ticket and config.
Reads the rules file and renders it into the system prompt template. Serialises the full ticket as JSON for the user prompt.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in rcpond/prompt.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
servicenow
A limited interface to ServiceNow.
Provides a class, ServiceNow, which wraps the ServiceNow
API. The only methods are:
ServiceNow.get_tickets(): Get a list of tickets. By default only unassigned tickets are returned, but all tickets can be selected;ServiceNow.get_ticket(): Get a single ticket by its ticket number (e.g."RES0001234");ServiceNow.get_full_ticket(): Get full details of a ticket;assign_to()Assigns a ticket to the named user;get_work_notes()List the work notes for a specific ticket; andpost_note()(Not implemented) Post a “work note” to a ticket.
Tickets are returned as instances of a Ticket dataclass which
contains a few, high-level details. The subclass FullTicket contains
,in addition, the fields submitted by the requestor on the request form.
The URL of the ServiceNow API is hardcoded, but you will need to supply a user authentication token.
This version filters out all tickets that are not requests for HPC or Azure resource.
Example use
the_sn = ServiceNow("ab...def") the_sn.get_tickets()
FullTicket
dataclass
Bases: Ticket
A ticket; includes full details from the original submission.
Source code in rcpond/servicenow.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
from_Ticket(t, **extras)
classmethod
Create a new FullTicket starting from a Ticket and passing only the additional fields.
Source code in rcpond/servicenow.py
165 166 167 168 169 170 171 172 | |
NoteEntry
dataclass
A single parsed work note or comment from a ServiceNow ticket.
Source code in rcpond/servicenow.py
122 123 124 125 126 127 128 129 130 131 132 133 | |
content
instance-attribute
Body text of the note, with the header line stripped.
datetime_stamp
instance-attribute
Parsed timestamp of the note.
note_type
instance-attribute
Note category as returned by ServiceNow, e.g. "Work notes" or "Comments".
user
instance-attribute
Display name of the author.
ServiceNow
Simple wrapper around limited parts of the ServiceNow API.
Source code in rcpond/servicenow.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
assign_to(ticket, assignee)
Assign the current user to a ticket.
Post-hoc validation is performed that this assignee exists in the ServiceNow instance. If an invalid value for assignee is provided. The method will assign the ticket to the invalid user, detect that it is invalid, and then revert the assignment to the original assignee. This interaction will show in the Activity log for the ticket in the ServiceNow WebUI
Example:
sn.assign_to(my_tkt, "sam@example.com")
To unassign a ticket, set assignee == "":
sn.assign_to(my_tkt, "")
Params: ticket: The ticket to be assigned assignee: The email address or sys_id (as a str) of the user to assign the ticket to.
Returns:
A dict with two keys display_value and value
Source code in rcpond/servicenow.py
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
assign_to_me(ticket)
Assign ticket to the currently authenticated OAuth user.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Source code in rcpond/servicenow.py
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | |
get_assignee(tkt)
A convenience method to retrieve the current assigned_to field for a Ticket.
returns:
A dict with two keys display_value and value
Source code in rcpond/servicenow.py
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
get_full_ticket(tkt)
Get full ticket details.
Source code in rcpond/servicenow.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
get_ticket(ticket_number)
Returns the unique ticket matching ticket_number, or raise ValueError if either no match,
or multiple matches are found.
The specified ticket may be assigned or unassigned
| Parameters: |
|
|---|
| Raises: |
|
|---|
Source code in rcpond/servicenow.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
get_tickets(long_list=False)
Get tickets that are applications for HPC/Azure credits.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in rcpond/servicenow.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
post_note(tkt, note)
Post a work note to a ticket.
Params: tkt: The ticket note: The note to post
Source code in rcpond/servicenow.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | |
web_url(tkt)
Return the ServiceNow Web UI URL for tkt.
| Parameters: |
|
|---|
Source code in rcpond/servicenow.py
343 344 345 346 347 348 349 350 351 | |
Ticket
dataclass
A ticket; contains only high-level details about the ticket.
Source code in rcpond/servicenow.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
assigned_to
instance-attribute
Display name of the assigned agent, or empty string if unassigned.
comments
instance-attribute
Raw display_value string for additional comments, as returned by the ServiceNow API.
number
instance-attribute
The ticket number as recognised by agents.
opened_at
instance-attribute
A timestamp, formatted as DD/MM/YYYY HH:MM:SS
state
instance-attribute
Human-readable ticket state, e.g. 'New', 'In Progress', 'On Hold', 'Resolved', 'Closed'.
sys_id
instance-attribute
The internal ServiceNow identifier for the ticket.
work_notes
instance-attribute
Raw display_value string for work notes, as returned by the ServiceNow API.
assign_to_me(service_now)
Assign this ticket to the currently authenticated OAuth user.
| Parameters: |
|
|---|
| Raises: |
|
|---|
Source code in rcpond/servicenow.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
get_combined_notes()
Return work notes and comments merged and sorted chronologically (oldest first).
| Returns: |
|
|---|
Source code in rcpond/servicenow.py
87 88 89 90 91 92 93 94 95 96 97 98 | |
is_rcpond_most_recent_process()
Returns True if the current version of RCPond posted the most recent Comment or Work Note on this ticket. False otherwise.
Source code in rcpond/servicenow.py
104 105 106 107 | |
is_rcpond_processed()
Returns True if RCPond (any version) has ever posted a Comment or Work Note on this ticket. False otherwise.
Source code in rcpond/servicenow.py
100 101 102 | |
refresh(service_now)
Refresh mutable fields by re-querying the ServiceNow API.
| Parameters: |
|
|---|
Source code in rcpond/servicenow.py
109 110 111 112 113 114 115 116 117 118 119 | |
tool
Generic LLM tool interface.
Provides:
Tool: Abstract base class for LLM tools. Each tool exposes its schema viato_openai_dict()and runs its action viaexecute().
Concrete implementations live in rcpond.tools.
Example use
class MyTool(Tool): ... @property ... def name(self) -> str: ... return "my_tool" ... ... @property ... def description(self) -> str: ... return "Does something." ... ... def to_openai_dict(self) -> dict: ... ... def execute(self, service_now, ticket, **kwargs) -> None: ...
Tool
Bases: ABC
Abstract base class for an LLM tool.
Subclasses define their own schema (to_openai_dict) and execution logic
(execute). The name and description properties drive both the
schema and tool-call dispatch in command.py.
Source code in rcpond/tool.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
description
abstractmethod
property
The human-readable description exposed to the LLM.
name
abstractmethod
property
The function name exposed to the LLM.
execute(service_now, ticket, **kwargs)
abstractmethod
Execute this tool's action.
| Parameters: |
|
|---|
Source code in rcpond/tool.py
63 64 65 66 67 68 69 70 71 72 73 74 75 | |
to_openai_dict()
abstractmethod
Return this tool's schema in OpenAI function-calling format.
| Returns: |
|
|---|
Source code in rcpond/tool.py
53 54 55 56 57 58 59 60 61 | |
tools
rcpond-specific tool definitions.
Provides:
PostFreeformNoteTool: Posts a freeform LLM-written note to ServiceNow.PostTemplatedNoteTool: Renders a Jinja2 template selected by the LLM and posts it.get_available_tools: Returns the list of tools available to the LLM.
The generic Tool ABC is defined in rcpond.tool.
Example use
tools = get_available_tools(config)
response = llm.generate(system, user, model, tools=tools)
if response.planned_tool_call:
name = response.planned_tool_call["function"]["name"]
args = response.planned_tool_call["function"]["arguments"]
for t in tools:
if t.name == name:
t.execute(service_now, ticket, **args)
PostFreeformNoteTool
Bases: Tool
Posts a freeform work note written by the LLM to the ServiceNow ticket.
Example:
tool = PostFreeformNoteTool()
Source code in rcpond/tools.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
PostTemplatedNoteTool
Bases: Tool
Renders a Jinja2 template selected by the LLM and posts it as a work note.
Templates are read from email_templates_dir. The ticket object is
available in every template as {{ ticket.<field> }}. All other variables
are supplied by the LLM.
Example:
tool = PostTemplatedNoteTool(config)
Source code in rcpond/tools.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
to_openai_dict()
Templates prefixed '_' are omitted from the template_name enum but their variables are still surfaced to the LLM.
Source code in rcpond/tools.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
get_available_tools(config)
Return the list of tools available to the LLM.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in rcpond/tools.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |