LlamaIndex Integration Blueprint

Review risky retrieval before sources become an answer.

Use Stacksona after retrieval and before final synthesis when the answer depends on restricted sources, missing citations, or high-impact recommendations.

Governance object: retrieved nodes + citation/source policy.

Where Stacksona sits

The useful integration point is the last safe moment before an external action, privileged read, or customer-visible response occurs.

Implementation steps

Use these steps as the first implementation pass. Start with one high-risk action, verify the reviewer workflow, then expand coverage.

  1. Classify retrieval resultsFlag restricted indexes, low-confidence chunks, customer data, missing citations, or sources that require approval.
  2. Gate before synthesisPause after retrieving nodes but before the response synthesizer produces a final answer.
  3. Send source-level contextInclude source ids, titles, scores, policy labels, prompt intent, and the planned answer type.
  4. Constrain final outputIf approved, pass reviewer requirements such as citation count, redactions, or prohibited claims into synthesis.
Recommended package

Use the Stacksona SDK or API wrapper

For Node.js or TypeScript guard services, start with the live SDK. For Python runtimes, call the same guard through your backend or a small HTTP wrapper.

npm i @stacksona/sdk
View SDK on npm

Approval payload to send

Keep the payload compact enough for a reviewer to decide quickly, but specific enough to explain exactly what the agent wants to do.

FieldWhat to include
agentStable name for the agent, crew, graph, or workflow that is asking for approval.
actionHuman-readable verb such as send_email, issue_refund, or execute_tool.
riskUse low, medium, or high so reviewers can triage quickly.
subjectThe customer, ticket, repository, account, or data source affected by the action.
contextSmall, reviewable facts: proposed arguments, policy signals, retrieved sources, role, task id, and links.

Retrieval policy guard

starter pattern
def governed_query(query, retriever, synthesizer):
    nodes = retriever.retrieve(query)
    risk = classify_retrieval_risk(nodes)

    decision = gate_request({
        "agent": "research-assistant",
        "action": "synthesize_answer",
        "risk": risk,
        "subject": query,
        "context": {
            "source_ids": [node.node_id for node in nodes],
            "source_titles": [node.metadata.get("title") for node in nodes],
            "policy_labels": collect_policy_labels(nodes),
        },
    })

    if decision["status"] != "approved":
        return "Answer paused for source review."
    return synthesizer.synthesize(query, nodes, citation_required=True)

Treat this as the shape of the guard. Replace gate_request, stacksona.gate.request, or run_tool with the SDK/API calls used in your runtime.

Practical guidance

Best gate points

Post-retrieval, pre-synthesis, or before sending answers to external channels.

Reviewer context

Source metadata, sensitivity labels, citation status, and intended audience.

Avoid

Do not wait until after final answer generation to discover restricted-source use.