33# AIQ Research Skill
34
35## Purpose
36
37Use this skill to call a locally running NVIDIA AI-Q Blueprint server through the helper script at
38scripts/aiq.py.
39
40Use this skill for research-shaped requests, including:
41
42- "deep research on ..."
43- "AIQ research ..."
44- "research ..."
45- "use AI-Q to answer ..."
46- "ask AI-Q about ..."
47
48Do not use this skill for install, deploy, start, stop, UI, CLI, Docker, Helm, or troubleshooting requests. Those
49belong to aiq-deploy.
50
51## Prerequisites
52
53Users need:
54
55- Python 3.11+ available as python3.
56- A reachable local or self-hosted AI-Q Blueprint backend.
57- AIQ_SERVER_URL set when the backend is not running at http://localhost:8000; non-local values must be trusted by
58 the user before any query is sent.
59- A backend configured with authentication disabled for this public helper, or a separate authenticated AI-Q skill for
60 authenticated environments.
61- Network access from the local machine to the AI-Q backend URL.
62- Credentials configured in the backend environment, not in this skill. This public helper does not collect or manage
63 API keys.
64
65The helper script has no third-party Python package dependencies; it uses Python standard-library HTTP modules.
66
67## Instructions
68
691. Resolve the target backend URL.
702. Run health before sending research requests.
713. If no backend is reachable, ask for a backend URL or hand off to aiq-deploy.
724. Before sending any user query, state the exact AI-Q backend URL that will receive it. For non-local URLs, continue
73 only if the user has explicitly confirmed that URL is trusted in the current conversation.
745. Poll asynchronous deep research jobs when AI-Q returns a job ID.
756. Present returned reports with citations and source URLs intact.
767. Stop on failed jobs and show the returned error; do not retry automatically.
778. After presenting a report, support follow-up: answer questions about it
78 (ask) or run a refined research pass (redo) using the same commands.
79
80### Step 1 - Resolve the backend
81
82Use AIQ_SERVER_URL when set. Otherwise try the default local backend:
83
84```bash
85python3 $SKILL_DIR/scripts/aiq.py health
86```
87
88Expected output: JSON from a reachable AI-Q health endpoint.
89
90If health fails and no explicit AIQ_SERVER_URL was set, ask:
91
92```text
93I do not see a reachable local AI-Q backend. Do you already have an AI-Q backend URL you want to use, or should I deploy a local Skill backend?
94```
95
96- If the user provides a URL, set AIQ_SERVER_URL for subsequent helper calls and rerun health.
97- If the user wants local deployment, hand off to aiq-deploy and preserve the original research request.
98- If a reachable backend returns 401 or 403, stop and explain that this public skill does not manage
99 authentication. Ask the user to use an authenticated AI-Q skill or configure authentication for their environment.
100- If health succeeds but /chat or /v1/jobs/async/agents fails, report that the backend is reachable but not
101 compatible with this public research flow, then offer to run aiq-deploy validation.
102
103### Step 2 - Send the routed research request
104
105Before sending the request, state the resolved endpoint:
106
107```text
108I will send this query to <AIQ_SERVER_URL>. Make sure this endpoint is trusted before sending sensitive information.
109```
110
111Do not send credentials, cookies, bearer tokens, or secret values through the query text.
112
113Run:
114
115```bash
116python3 $SKILL_DIR/scripts/aiq.py chat "<USER_QUESTION>"
117```
118
119Expected output:
120
121- A normal JSON response for shallow or direct answers.
122- Or structured JSON containing {"status": "deep_research_running", "job_id": "<JOB_ID>"} for asynchronous deep
123 research.
124
125If the response is normal JSON, present the result immediately. Do not force polling when there is no job_id.
126
127### Step 3 - Poll asynchronous jobs
128
129If the response includes deep_research_running, extract the job_id and poll with the same absolute script path:
130
131```bash
132python3 $SKILL_DIR/scripts/aiq.py research_poll <JOB_ID>
133```
134
135Expected output: the final report JSON when the job completes successfully.
136
137Use the runtime's non-blocking or background execution mechanism when available. If the chosen execution method requires
138escalated permissions, request explicit user approval first and explain why. Tell the user that deep research is running
139in the background.
140
141### Step 4 - Resume after interruptions
142
143If polling is interrupted, the job continues server-side. Resume with:
144
145```bash
146python3 $SKILL_DIR/scripts/aiq.py status <JOB_ID>
147python3 $SKILL_DIR/scripts/aiq.py report <JOB_ID>
148python3 $SKILL_DIR/scripts/aiq.py research_poll <JOB_ID>
149```
150
151Use status to inspect job status and saved artifacts. Use report when the job has already finished and you only need
152the final output. Use research_poll to keep waiting for completion.
153
154The final report may reference generated artifacts (charts, CSVs) as artifact://<id> links. To materialize them as local
155files, run python3 $SKILL_DIR/scripts/aiq.py artifacts <JOB_ID> --download-dir ./aiq-artifacts; it downloads each artifact
156and prints the local path. Do not expect base64 image data in the report itself.
157
158For a self-contained, shareable report, run python3 $SKILL_DIR/scripts/aiq.py report <JOB_ID> --out-dir ./my-report. It writes report.md plus an
159artifacts/ folder and rewrites each artifact://<id> link to the matching local file, so the report renders (charts and
160all) in any markdown viewer without a running backend.
161
162### Step 5 - Present the report
163
164When research_poll completes successfully, fetch and present the full report. Keep citations and source URLs intact.
165If the job status is failed, failure, or cancelled, show the error from the status response and ask whether the
166user wants to retry with a narrower query or different approach.
167
168### Step 6 - Follow up: ask about, edit, or redo a report
169
170After a report is presented, the user often wants to go deeper or adjust scope.
171Reuse the existing backend flow — the same auth boundary, polling, and report
172retrieval from Steps 1-5 apply; there is no separate follow-up endpoint.
173
174**Ask** — a follow-up question about a report already in hand:
175
176- For a question answerable from the report you already have, answer directly
177 from its content and citations; do not call the backend again.
178- For a question that needs new investigation, send a fresh request that carries
179 the needed context from the prior question and report into the new query
180 text, then present the new result:
181
182 ```bash
183 python3 $SKILL_DIR/scripts/aiq.py chat "<FOLLOW_UP_QUESTION> (context: <PRIOR_TOPIC>)"
184 ```
185
186 If this returns a deep_research_running job ID, poll it with research_poll
187 exactly as in Step 3.
188
189**Edit** — rewrite a report with cosmetic changes. This skill only has access
190to the data used to generate the initial report. No tools are available:
191
192```bash
193python3 $SKILL_DIR/scripts/aiq.py report_edit <JOB_ID> "<EDIT_INSTRUCTIONS>"
194```
195
196**Redo** — re-run research with adjusted scope (a narrower query, a corrected
197question, or a different depth):
198
199```bash
200python3 $SKILL_DIR/scripts/aiq.py research "<REFINED_QUERY>" [agent_type]
201```
202
203- Choose agent_type to match the desired depth (for example a deep agent for a
204 thorough pass, or shallow_researcher for a quick one); list options with
205 agents if unsure.
206- Treat a redo as a new job: state the target endpoint again before sending
207 (Step 2), then poll and present as in Steps 3-5.
208
209Do not send credentials or secret values in follow-up query text, and keep
210citations and source URLs intact in every follow-up answer.
211
212## Version Compatibility
213
214**IMPORTANT:** This skill is designed for NVIDIA AI-Q Blueprint version 2.1.0.
215
216Semantic Versioning Compatibility Rules:
217
218```text
219Skill version: X.Y.Z
220Blueprint or endpoint version: A.B.C
221
222Compatible IF:
2231. A == X (Major versions MUST match)
2242. B >= Y (Minor version must be equal or greater)
2253. C can be anything (Patch version does not affect compatibility)
226```
227
228Examples:
229
230- Skill version 2.1.0 is compatible with Blueprint version 2.1.0.
231- Skill version 2.1.0 is compatible with Blueprint version 2.2.0.
232- Skill version 2.1.0 is compatible with Blueprint version 2.1.5.
233- Skill version 2.1.0 is not compatible with Blueprint version 3.0.0.
234- Skill version 2.1.0 is not compatible with Blueprint version 2.0.0.
235
236If your Blueprint version is not compatible:
237
2381. Check for an updated skill version matching your Blueprint version.
2392. Use a Blueprint version compatible with this skill.
2403. Proceed with caution only when the user accepts the compatibility risk; API routes or response shapes may have
241 changed.
242
243## Available Scripts
244
245| Script | Purpose | Arguments |
246|---|---|---|
247| scripts/aiq.py health | Check whether the configured server responds | none |
248| scripts/aiq.py chat | POST /chat; may return inline output or a deep-research job ID | <query> |
249| scripts/aiq.py agents | List available async agent types | none |
250| scripts/aiq.py submit | Submit an explicit async job | <query> [agent_type] |
251| scripts/aiq.py research | Submit an async job, poll, and print the final report JSON | <query> [agent_type] |
252| scripts/aiq.py research_poll | Resume polling an existing async job | <job_id> |
253| scripts/aiq.py status | Fetch job status plus /state artifacts | <job_id> |
254| scripts/aiq.py state | Fetch event-store artifacts only | <job_id> |
255| scripts/aiq.py report | Fetch the final report; with --out-dir DIR, export a portable report.md + artifacts/ folder with links rewritten to local files | <job_id> [--out-dir DIR] |
256| scripts/aiq.py report_edit | Edit a completed report with cosmetic changes | <job_id> <edit_instructions> |
257| scripts/aiq.py artifacts | List durable artifacts; with --download-dir DIR, download them and print local paths | <job_id> [--download-dir DIR] |
258| scripts/aiq.py stream | Stream SSE events from a job | <job_id> |
259| scripts/aiq.py cancel | Cancel a running job | <job_id> |
260
261When the host supports a run_script() helper, call it with scripts/aiq.py and the arguments above. Otherwise, run
262the equivalent shell command, such as python3 $SKILL_DIR/scripts/aiq.py health.
263
264## Environment Variables
265
266| Variable | Required | Default | Description |
267|---|---:|---|---|
268| AIQ_SERVER_URL | No | http://localhost:8000 | Local or self-hosted AI-Q server base URL |
269
270## Security Best Practices
271
272- Do not put API keys, bearer tokens, cookies, or basic-auth credentials in AIQ_SERVER_URL.
273- Store backend credentials in the AI-Q deployment environment, not in this skill or command examples.
274- User query text is transmitted to the configured AIQ_SERVER_URL. Confirm the endpoint is trusted before sending
275 sensitive or confidential information.
276- Treat returned reports as potentially sensitive if the backend uses private data sources.
277- Do not truncate citations or source URLs from returned reports.
278
279## Limitations
280
281- This skill requires a running AI-Q backend; it does not deploy one.
282- The public helper does not manage authentication tokens or cookies.
283- Remote AIQ_SERVER_URL endpoints may log prompts, responses, and metadata.
284- If the backend returns HTTP 500 or lacks async agents, report the failure instead of fabricating a research answer.
285
286## Examples
287
288### Example 1: Run a routed chat or research request
289
290```bash
291python3 $SKILL_DIR/scripts/aiq.py health
292python3 $SKILL_DIR/scripts/aiq.py chat "Compare local AIQ deep research with a standard web search workflow"
293```
294
295Expected output:
296
297```text
298<health JSON from AI-Q>
299<JSON chat response or {"status": "deep_research_running", "job_id": "<JOB_ID>"}>
300```
301
302If AI-Q returns a job ID, continue with research_poll.
303
304### Example 2: Resume an existing job
305
306```bash
307python3 $SKILL_DIR/scripts/aiq.py status <JOB_ID>
308python3 $SKILL_DIR/scripts/aiq.py research_poll <JOB_ID>
309```
310
311Replace <JOB_ID> with the UUID returned by AI-Q. Expected output: status JSON followed by the report JSON when the
312job completes. If the job failed, show the returned status and do not retry automatically.
313
314### Example 3: Ask a follow-up or redo with a refined query
315
316```bash
317# Ask: a follow-up that needs new investigation, carrying prior context.
318python3 $SKILL_DIR/scripts/aiq.py chat "How does that compare on cost? (context: local AIQ deep research vs web search)"
319
320# Redo: re-run research with a narrower query and explicit depth.
321python3 $SKILL_DIR/scripts/aiq.py research "AIQ deep research cost on a single workstation" shallow_researcher
322```
323
324Expected output: a routed chat response or a new deep_research_running job ID
325to poll with research_poll. Present the follow-up answer with citations and
326source URLs intact.
327
328## References
329
330| Topic | Documentation |
331|---|---|
332| Helper script | scripts/aiq.py |
333| Deployment and backend validation | ../aiq-deploy/SKILL.md |
334
335## Common Issues
336
337### Issue: No backend is reachable
338
339**Symptoms:**
340
341- health fails with connection refused.
342- The default http://localhost:8000 URL does not respond.
343
344**Causes:**
345
346- AI-Q is not running.
347- AI-Q is running on a different host or port.
348- A local firewall or network setting blocks the connection.
349
350**Solutions:**
351
3521. Ask whether the user has an existing AI-Q backend URL.
3532. If they provide one, set it and rerun health:
354 ```bash
355 export AIQ_SERVER_URL="http://localhost:<PORT>"
356 python3 $SKILL_DIR/scripts/aiq.py health
357 ```
3583. If they want a local backend, hand off to aiq-deploy and preserve the original research request.
359
360### Issue: Backend requires authentication
361
362**Symptoms:**
363
364- Requests fail with HTTP 401 or HTTP 403.
365- The backend is reachable but rejects /chat or async job calls.
366
367**Causes:**
368
369- The backend was deployed with authentication enabled.
370- The public helper does not attach user tokens or cookies.
371
372**Solutions:**
373
3741. Stop and explain that this public skill does not manage authentication.
3752. Ask the user to use an authenticated AI-Q skill or configure their backend for this public local workflow.
3763. Rerun health and the original query only after the authentication boundary is resolved.
377
378### Issue: Health succeeds but research routes fail
379
380**Symptoms:**
381
382- health returns successfully.
383- /chat, /v1/jobs/async/agents, or polling commands fail.
384
385**Causes:**
386
387- The backend is not using an API-enabled AI-Q config.
388- The async job registry is not available in the selected backend.
389- The backend version is incompatible with this skill.
390
391**Solutions:**
392
3931. Run:
394 ```bash
395 python3 $SKILL_DIR/scripts/aiq.py agents
396 ```
3972. If agents are unavailable, report the compatibility failure and offer to run aiq-deploy validation.
3983. Confirm the deployed Blueprint version is compatible with skill version 2.1.0.
399
400### Issue: Job is interrupted or appears stuck
401
402**Symptoms:**
403
404- Local polling is interrupted.
405- The job keeps showing running.
406- Poll output shows running, but a report is returned or cancel says the job is already success.
407
408**Causes:**
409
410- Deep research is asynchronous and continues server-side.
411- Local polling output can lag behind terminal server state.
412
413**Solutions:**
414
4151. Check current state:
416 ```bash
417 python3 $SKILL_DIR/scripts/aiq.py status <JOB_ID>
418 ```
4192. If has_report: true or job_status.status: success, fetch the report:
420 ```bash
421 python3 $SKILL_DIR/scripts/aiq.py report <JOB_ID>
422 ```
4233. If the job is still running, continue polling:
424 ```bash
425 python3 $SKILL_DIR/scripts/aiq.py research_poll <JOB_ID>
426 ```
427