Skip to main content

Live test run — working principle & results

This page explains how Advisor works end-to-end, then records a real run against QueryCraft + OpenAI (restaurant shop id 11, 2026-07-22).

Related guides: Pipeline · Sessions · Postman · Redoc


Working principle

Advisor is not “one chat call.” It is a staged pipeline. Each stage has its own HTTP API so you can test it alone.

Owner problem (plain language)


┌───────────────────┐
│ 1. Auth │ Who is the restaurant? → principalId / shop_id
└─────────┬─────────┘

┌───────────────────┐
│ 2. Catalog │ Load playbooks + recommendations (YAML, no LLM)
└─────────┬─────────┘

┌───────────────────┐
│ 3. Classify │ Problem text → 1–2 playbook_ids (OpenAI purpose=classify)
└─────────┬─────────┘

┌───────────────────┐
│ 4. Query (optional)│ Single analytics ask — same engine the agent uses
│ /api/query/ask │ → QueryCraft POST /query/nlp (can take 15–120s)
└─────────┬─────────┘

┌───────────────────┐
│ 5. Advisor session│ Agent loop (OpenAI purpose=investigate + tools)
│ start / answers│
└─────────┬─────────┘

concluded diagnosis
(or awaiting_manager → resume with answers)

What the agent actually does

Inside POST /api/advisor/sessions the investigate model may call tools repeatedly:

ToolPurpose
query_dataAsk QueryCraft (counts toward query_count, default max 8)
ask_managerPause session → status: awaiting_manager (max 3)
update_hypothesisMove items on the hypothesis board
select_playbookSwitch / add playbook focus
conclude_diagnosisEmit finding, evidence, actions, verification window

Prompt blocks:

BlockRole
AMethod, tone, hard rules (src/application/agent/block-a.ts)
BThis restaurant’s domains / channels (tenant + data-domains)
CSelected playbook(s) + live hypothesis board

Important distinction

CallWhat it proves
POST /api/query/askQueryCraft NLP + SQL + rows only
POST /api/advisor/sessionsFull Advisor: classify → tool loop → diagnosis

A successful query ask does not mean Advisor is configured. Advisor needs LLM_ADAPTER=openai (or mock for offline demos) and usually QUERY_ADAPTER=querycraft for live numbers.


Env used for this live run

AUTH_ADAPTER=querycraft
QUERY_ADAPTER=querycraft
LLM_ADAPTER=openai
OPENAI_ENABLED=true
CATALOG_ADAPTER=yaml
QUERYCRAFT_ENABLED=true
QUERYCRAFT_URL=https://querycraft.ncrts.pro
QUERYCRAFT_TIMEOUT_MS=120000

Notes:

  • QueryCraft NLP often needs 1–2 minutes; keep QUERYCRAFT_TIMEOUT_MS120000 or the Advisor aborts with This operation was aborted.
  • With LLM_ADAPTER=mock, sessions return a scripted diagnosis and do not exercise a real investigate loop.

Confirm wiring:

GET /api/health

Expect adapters.llm = openai, adapters.query = querycraft, thirdParty.querycraft.timeoutMs = 120000.


Live run (shop 11) — step by step

Problem statement used throughout:

{ "problem_statement": "sales are down across the board" }

Step A — Auth

POST /api/auth/login → Bearer token
GET /api/auth/me

FieldValue
principalId / shop11
Display nameJessica Parker
Rolesrestaurant, admin

All later QueryCraft SQL is scoped to this shop.

Step B — Classify (Advisor brain, cheap model)

POST /api/classify

FieldResult
Time~3s
playbook_ids["demand-decline"]
sourcellm
adapters.llmopenai

Step C — Query alone (QueryCraft only — not full Advisor)

POST /api/query/ask

{ "question": "What were total sales yesterday?" }
FieldResult
HTTP200 in ~25s
kinddata
Rowssales_amount / formatted_sales$41.48
Scopeshop_id = 11, order_date = '2026-07-21'

This validates data access. It does not produce a diagnosis.

Step D — Start Advisor session (full loop)

POST /api/advisor/sessions with the same problem statement.

FieldResult
HTTP201 in ~260s
session_id0mrw7fpnsf70b794c05585ce7f
status / stopawaiting_manager
playbook_idsdemand-decline
query_count4 (four live QueryCraft tool calls)
ask_count1
diagnosis(none yet)

Hypothesis board after data probes

HypothesisStatusNote (short)
seasonality_not_declineruled_outYoY/recent drop looks real, not seasonality
retention_leakinginvestigatingCohort repeat high but sample tiny
acquisition_dried_upinconclusiveNew-vs-returning query failed
channel_visibility_lossruled_outDecline across channels

Pending manager questions

  1. dq-01 — Has discovery changed (ads, signage, neighbor traffic)?
  2. dq-03 — Location changes (construction, parking, competitor)?

Step E — Resume with answers

POST /api/advisor/sessions/{id}/answers

Sample answers used in the test:

{
"answers": [
{
"probe_id": "dq-01",
"answer": "We paused Facebook ads about 6 weeks ago and have not run any promos since."
},
{
"probe_id": "dq-03",
"answer": "Street construction started nearby 2 months ago; parking is harder. No new competitor that we know of."
}
]
}
FieldResult
HTTP200 in ~9s
status / stopconcluded
query_countstill 4
verify_after2026-08-19

Updated board: acquisition_dried_upsupported (ads paused + no promos).

Diagnosis (summary)

FieldValue
FindingDecline driven mainly by weaker acquisition after ads/promos stopped
Confidenceconfirmed
Confirmed hypothesisacquisition_dried_up
Actionlocal-visibility-audit (revive local visibility / marketing)
Verificationcheck_after_days: 28, probe dv-01

Step F — Snapshot

GET /api/advisor/sessions/0mrw7fpnsf70b794c05585ce7f
Returns the same concluded state (does not re-run the agent).


Postman order for this path

  1. GET {{baseUrl}}/api/health — confirm openai + querycraft + timeout
  2. POST {{baseUrl}}/api/auth/login — save token
  3. POST {{baseUrl}}/api/classify — problem statement
  4. (optional) POST {{baseUrl}}/api/query/ask — prove data
  5. POST {{baseUrl}}/api/advisor/sessionswait several minutes; save session_id
  6. If awaiting_managerPOST .../sessions/{{sessionId}}/answers
  7. GET .../sessions/{{sessionId}}

Set Postman request timeout ≥ QUERYCRAFT_TIMEOUT_MS (e.g. 120000+ ms). A session with several query_data calls can take 5–10+ minutes.


Failure modes we hit while building this run

SymptomCauseFix
502operation was aborted ~15sQUERYCRAFT_TIMEOUT_MS=15000Raise to 120000+, restart
Session concludes in ~1s with “Mock diagnosis…”LLM_ADAPTER=mockSet openai + OPENAI_ENABLED=true
Query ask works, “Advisor does nothing real”Only step 4 testedCall /api/advisor/sessions with OpenAI

What is still stubbed

  • Scheduled verification job (~14–28 days after verify_after)
  • Notify webhook when verification is due
  • SSE streaming of tool events (responses are sync JSON today)

See Tweaking to change prompts, playbooks, models, and caps.

Day chronicle: Work log — 2026-07-22.